Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
feat(expression_transformer): Parse NgTemplateCache values
Browse files Browse the repository at this point in the history
Parse html files from NgTemplateCache annotations for expressions, allowing developers the ease
of including files needed to be parsed without specifying them individually in the pubspec.yaml
definition.

Closes #1644
  • Loading branch information
Ted Sander authored and rkirov committed Feb 2, 2015
1 parent 6a66bd0 commit feccc0b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/tools/transformer/expression_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class ExpressionGenerator extends Transformer with ResolverTransformer {
.toList();

// Get all of the contents of templates in @Component(templateUrl:'...')
gatherReferencedUris(transform, resolver, options,
templatesOnly: true).then((templates) {
gatherReferencedUris(transform, resolver, options).then((templates) {
templates.values.forEach(controller.add);
}).then((_) {
// Add any HTML files referencing this Dart file.
Expand Down
35 changes: 35 additions & 0 deletions test/tools/transformer/expression_generator_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@ main() {
symbols: []);
});

it('should follow template cache uris', () {
return generates(phases,
inputs: {
'a|web/main.dart': '''
import 'package:angular/angular.dart';
import 'package:angular/cacheAnnotation.dart';
@NgTemplateCache(
preCacheUrls: ['lib/foo.html', 'packages/b/bar.html'])
class FooClass {}
main() {}
''',
'a|lib/foo.html': '''
<div>{{template.contents}}</div>''',
'b|lib/bar.html': '''
<div>{{bar}}</div>''',
'a|web/index.html': '''
<script src='main.dart' type='application/dart'></script>''',
'angular|lib/angular.dart': libAngular,
'angular|lib/cacheAnnotation.dart': libCacheAnnotation,
},
getters: ['template', 'contents', 'bar'],
setters: ['template', 'contents', 'bar'],
symbols: []);
});

it('should generate expressions for variables found in superclass', () {
return generates(phases,
inputs: {
Expand Down Expand Up @@ -248,3 +275,11 @@ class NgAttr {
const NgAttr(String attrName);
}
''';

const String libCacheAnnotation = '''
library angular.template_cache_annotation;
class NgTemplateCache {
const NgTemplateCache({List preCacheUrls, bool cache});
}
''';

0 comments on commit feccc0b

Please sign in to comment.