Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: pkg/polymer/lib/src/transform/code_extractor.dart

Issue 22852013: Fix polymer transformers in windows. AssetId's always use posix style paths (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/pkg.status ('k') | pkg/polymer/lib/src/transform/common.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** Transfomer that extracts inlined script code into separate assets. */ 5 /** Transfomer that extracts inlined script code into separate assets. */
6 library polymer.src.transformers; 6 library polymer.src.transformers;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 12 matching lines...) Expand all
23 Future apply(Transform transform) { 23 Future apply(Transform transform) {
24 var inputId = transform.primaryId; 24 var inputId = transform.primaryId;
25 return getPrimaryContent(transform).then((content) { 25 return getPrimaryContent(transform).then((content) {
26 var document = parseHtml(content, inputId.path, transform.logger); 26 var document = parseHtml(content, inputId.path, transform.logger);
27 int count = 0; 27 int count = 0;
28 for (var tag in document.queryAll('script')) { 28 for (var tag in document.queryAll('script')) {
29 if (tag.attributes['type'] == 'application/dart' && 29 if (tag.attributes['type'] == 'application/dart' &&
30 !tag.attributes.containsKey('src')) { 30 !tag.attributes.containsKey('src')) {
31 // TODO(sigmund): should we automatically include a library directive 31 // TODO(sigmund): should we automatically include a library directive
32 // if it doesn't have one? 32 // if it doesn't have one?
33 var filename = path.basename(inputId.path); 33 var filename = path.url.basename(inputId.path);
34 tag.attributes['src'] = '$filename.$count.dart'; 34 tag.attributes['src'] = '$filename.$count.dart';
35 var textContent = tag.nodes.first; 35 var textContent = tag.nodes.first;
36 var id = inputId.addExtension('.$count.dart'); 36 var id = inputId.addExtension('.$count.dart');
37 transform.addOutput(new Asset.fromString(id, textContent.value)); 37 transform.addOutput(new Asset.fromString(id, textContent.value));
38 textContent.remove(); 38 textContent.remove();
39 count++; 39 count++;
40 } 40 }
41 } 41 }
42 transform.addOutput(new Asset.fromString(inputId, 42 transform.addOutput(new Asset.fromString(inputId,
43 count == 0 ? content : document.outerHtml)); 43 count == 0 ? content : document.outerHtml));
44 }); 44 });
45 } 45 }
46 } 46 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | pkg/polymer/lib/src/transform/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698