feat(dart/transform): Allow absolute urls in templates
Allow `templateUrl` to be specified as an absolute `package:` import.
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
library examples.src.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(HelloCmp, {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const View(template: r'''{{greeting}}''')
|
||||
]
|
||||
});
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
library examples.src.hello_world.index_common_dart;
|
||||
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
@Component(selector: 'hello-app')
|
||||
@View(templateUrl: 'package:other_package/template.html')
|
||||
class HelloCmp {}
|
@ -0,0 +1 @@
|
||||
{{greeting}}
|
@ -3,6 +3,7 @@ library angular2.test.transform.directive_processor.all_tests;
|
||||
import 'package:barback/barback.dart';
|
||||
import 'package:angular2/src/transform/directive_processor/rewriter.dart';
|
||||
import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
||||
import 'package:angular2/src/transform/common/asset_reader.dart';
|
||||
import 'package:dart_style/dart_style.dart';
|
||||
import 'package:guinness/guinness.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
@ -40,6 +41,13 @@ void allTests() {
|
||||
_testNgDeps(
|
||||
'should inline `templateUrl` values.', 'url_expression_files/hello.dart');
|
||||
|
||||
var absoluteReader = new TestAssetReader();
|
||||
absoluteReader.addAsset(new AssetId('other_package', 'lib/template.html'),
|
||||
readFile(
|
||||
'directive_processor/absolute_url_expression_files/template.html'));
|
||||
_testNgDeps('should inline `templateUrl` values expressed as absolute urls.',
|
||||
'absolute_url_expression_files/hello.dart', reader: absoluteReader);
|
||||
|
||||
_testNgDeps('should inline `templateUrl`s expressed as adjacent strings.',
|
||||
'split_url_expression_files/hello.dart');
|
||||
|
||||
@ -54,10 +62,13 @@ void allTests() {
|
||||
}
|
||||
|
||||
void _testNgDeps(String name, String inputPath,
|
||||
{List<AnnotationDescriptor> customDescriptors: const [], AssetId assetId}) {
|
||||
{List<AnnotationDescriptor> customDescriptors: const [], AssetId assetId,
|
||||
AssetReader reader}) {
|
||||
it(name, () async {
|
||||
var inputId = _assetIdForPath(inputPath);
|
||||
var reader = new TestAssetReader();
|
||||
if (reader == null) {
|
||||
reader = new TestAssetReader();
|
||||
}
|
||||
if (assetId != null) {
|
||||
reader.addAsset(assetId, await reader.readAsString(inputId));
|
||||
inputId = assetId;
|
||||
|
Reference in New Issue
Block a user