feat(transformers): provide a flag to disable inlining views
Add a flag to allow a user to disable inlining css/html content into the views. Closes #2658
This commit is contained in:
@ -58,6 +58,17 @@ void allTests() {
|
||||
'should inline multiple `styleUrls` values expressed as absolute urls.',
|
||||
'multiple_style_urls_files/hello.dart');
|
||||
|
||||
absoluteReader.addAsset(new AssetId('a', 'lib/template.html'),
|
||||
readFile('directive_processor/multiple_style_urls_files/template.html'));
|
||||
absoluteReader.addAsset(new AssetId('a', 'lib/template.css'),
|
||||
readFile('directive_processor/multiple_style_urls_files/template.css'));
|
||||
absoluteReader.addAsset(new AssetId('a', 'lib/template_other.css'), readFile(
|
||||
'directive_processor/multiple_style_urls_files/template_other.css'));
|
||||
_testNgDeps(
|
||||
'shouldn\'t inline multiple `styleUrls` values expressed as absolute '
|
||||
'urls.', 'multiple_style_urls_not_inlined_files/hello.dart',
|
||||
inlineViews: false, reader: absoluteReader);
|
||||
|
||||
_testNgDeps('should inline `templateUrl`s expressed as adjacent strings.',
|
||||
'split_url_expression_files/hello.dart');
|
||||
|
||||
@ -86,7 +97,7 @@ void allTests() {
|
||||
|
||||
void _testNgDeps(String name, String inputPath,
|
||||
{List<AnnotationDescriptor> customDescriptors: const [], AssetId assetId,
|
||||
AssetReader reader, List<String> expectedLogs}) {
|
||||
AssetReader reader, List<String> expectedLogs, bool inlineViews: true}) {
|
||||
it(name, () async {
|
||||
if (expectedLogs != null) {
|
||||
log.setLogger(new RecordingLogger());
|
||||
@ -105,7 +116,8 @@ void _testNgDeps(String name, String inputPath,
|
||||
var expectedId = _assetIdForPath(expectedPath);
|
||||
|
||||
var annotationMatcher = new AnnotationMatcher()..addAll(customDescriptors);
|
||||
var output = await createNgDeps(reader, inputId, annotationMatcher);
|
||||
var output =
|
||||
await createNgDeps(reader, inputId, annotationMatcher, inlineViews);
|
||||
if (output == null) {
|
||||
expect(await reader.hasInput(expectedId)).toBeFalse();
|
||||
} else {
|
||||
|
@ -0,0 +1,25 @@
|
||||
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}}''',
|
||||
styles: const [
|
||||
r'''.greeting { .color: blue; }''',
|
||||
r'''.hello { .color: red; }''',
|
||||
])
|
||||
]
|
||||
});
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
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(
|
||||
templateUrl: 'package:a/template.html',
|
||||
styleUrls: const [
|
||||
'package:a/template.css',
|
||||
'package:a/template_other.css'
|
||||
])
|
||||
]
|
||||
});
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
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:a/template.html',
|
||||
styleUrls: const ['package:a/template.css', 'package:a/template_other.css'])
|
||||
class HelloCmp {}
|
@ -0,0 +1 @@
|
||||
.greeting { .color: blue; }
|
@ -0,0 +1 @@
|
||||
{{greeting}}
|
@ -0,0 +1 @@
|
||||
.hello { .color: red; }
|
Reference in New Issue
Block a user