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

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

Issue 23543005: Make Transform a little more pleasant to use: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
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 /** Common methods used by transfomers. */ 5 /** Common methods used by transfomers. */
6 library polymer.src.transform.common; 6 library polymer.src.transform.common;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
11 import 'package:html5lib/dom.dart' show Document; 11 import 'package:html5lib/dom.dart' show Document;
12 import 'package:html5lib/parser.dart' show HtmlParser; 12 import 'package:html5lib/parser.dart' show HtmlParser;
13 import 'package:path/path.dart' as path; 13 import 'package:path/path.dart' as path;
14 import 'package:source_maps/span.dart' show Span; 14 import 'package:source_maps/span.dart' show Span;
15 15
16 // TODO(sigmund): delete this function (see dartbug.com/12515 and
17 // dartbug.com/12516)
Siggi Cherem (dart-lang) 2013/08/28 00:12:30 yay!
Bob Nystrom 2013/08/28 19:11:34 \o/
18 Future<String> getPrimaryContent(Transform transform) =>
19 transform.primaryInput.then((asset) => asset.readAsString());
20
21 // TODO(sigmund): delete this function (see dartbug.com/12515)
22 Future<String> getContent(Transform transform, AssetId id) =>
23 transform.getInput(id).then((asset) => asset.readAsString());
24
25 /** 16 /**
26 * Parses an HTML file [contents] and returns a DOM-like tree. Adds emitted 17 * Parses an HTML file [contents] and returns a DOM-like tree. Adds emitted
27 * error/warning to [logger]. 18 * error/warning to [logger].
28 */ 19 */
29 Document parseHtml(String contents, String sourcePath, TransformLogger logger, 20 Document parseHtml(String contents, String sourcePath, TransformLogger logger,
30 {bool checkDocType: true}) { 21 {bool checkDocType: true}) {
31 // TODO(jmesserly): make HTTP encoding configurable 22 // TODO(jmesserly): make HTTP encoding configurable
32 var parser = new HtmlParser(contents, encoding: 'utf8', generateSpans: true, 23 var parser = new HtmlParser(contents, encoding: 'utf8', generateSpans: true,
33 sourceUrl: sourcePath); 24 sourceUrl: sourcePath);
34 var document = parser.parse(); 25 var document = parser.parse();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 package = segments[1]; 65 package = segments[1];
75 targetPath = urlBuilder.join('asset', 66 targetPath = urlBuilder.join('asset',
76 urlBuilder.joinAll(segments.sublist(2))); 67 urlBuilder.joinAll(segments.sublist(2)));
77 } else { 68 } else {
78 package = source.package; 69 package = source.package;
79 targetPath = urlBuilder.normalize( 70 targetPath = urlBuilder.normalize(
80 urlBuilder.join(urlBuilder.dirname(source.path), url)); 71 urlBuilder.join(urlBuilder.dirname(source.path), url));
81 } 72 }
82 return new AssetId(package, targetPath); 73 return new AssetId(package, targetPath);
83 } 74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698