Skip to content

Commit 6258929

Browse files
sigmundchyjbanov
authored andcommitted
fix(transformer): fix 'pub build' in examples
1 parent 749d043 commit 6258929

File tree

19 files changed

+38
-21
lines changed

19 files changed

+38
-21
lines changed

modules/angular2/src/transform/directive_processor/visitors.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ class AnnotationsTransformVisitor extends ToSourceVisitor {
269269
writer.print("template: r'''");
270270
writer.asyncPrint(_readOrEmptyString(url));
271271
writer.print("'''");
272+
273+
// We keep the templateUrl in case the body of the template includes
274+
// relative urls that might be inlined later on (e.g. @import
275+
// directives or url() css values in style tags).
276+
writer.print(", templateUrl: r'$url'");
272277
return null;
273278
} else {
274279
logger.warning('template url is not a String $url');

modules/angular2/src/transform/template_compiler/change_detector_codegen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class _CodegenState {
122122
localNames.map((name) => '_${name}_pipe').toList();
123123

124124
void _writeToBuf(StringBuffer buf) {
125-
buf.write('''
125+
buf.write('''\n
126126
class $_changeDetectorTypeName extends $_BASE_CLASS {
127127
final dynamic $_DISPATCHER_ACCESSOR;
128128
$_GEN_PREFIX.PipeRegistry $_PIPE_REGISTRY_ACCESSOR;

modules/angular2/test/transform/directive_processor/absolute_url_expression_files/expected/hello.ng_deps.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library examples.src.hello_world.index_common_dart.ng_deps.dart;
1+
library examples.src.hello_world.absolute_url_expression_files.ng_deps.dart;
22

33
import 'hello.dart';
44
import 'package:angular2/angular2.dart'
@@ -16,6 +16,7 @@ void initReflector(reflector) {
1616
const Component(selector: 'hello-app'),
1717
const View(
1818
template: r'''{{greeting}}''',
19+
templateUrl: r'package:other_package/template.html',
1920
styles: const [r'''.greeting { .color: blue; }''',])
2021
]
2122
});

modules/angular2/test/transform/directive_processor/absolute_url_expression_files/hello.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library examples.src.hello_world.index_common_dart;
1+
library examples.src.hello_world.absolute_url_expression_files;
22

33
import 'package:angular2/angular2.dart'
44
show bootstrap, Component, Directive, View, NgElement;

modules/angular2/test/transform/directive_processor/all_tests.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ void _testNgDeps(String name, String inputPath,
124124
if (output == null) {
125125
expect(await reader.hasInput(expectedId)).toBeFalse();
126126
} else {
127-
expect(formatter.format(output)).toEqual(
128-
(await reader.readAsString(expectedId)).replaceAll('\r\n', '\n'));
127+
var input = await reader.readAsString(expectedId);
128+
expect(formatter.format(output)).toEqual(formatter.format(input));
129129
}
130130

131131
if (expectedLogs != null) {

modules/angular2/test/transform/directive_processor/expected/hello.ng_deps.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void initReflector(reflector) {
1616
const Component(selector: 'hello-app'),
1717
const View(
1818
template: r'''{{greeting}}''',
19+
templateUrl: r'template.html',
1920
styles: const [
2021
r'''.greeting { .color: blue; }''',
2122
r'''.hello { .color: red; }''',

modules/angular2/test/transform/directive_processor/invalid_url_files/expected/hello.ng_deps.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library test.transform.directive_processor.url_expression_files.hello.ng_deps.dart;
1+
library test.transform.directive_processor.invalid_url_files.hello.ng_deps.dart;
22

33
import 'hello.dart';
44
import 'package:angular2/angular2.dart'
@@ -14,7 +14,10 @@ void initReflector(reflector) {
1414
'parameters': const [],
1515
'annotations': const [
1616
const Component(selector: 'hello-app'),
17-
const View(template: r'''''', styles: const [r'''''', r'''''',])
17+
const View(
18+
template: r'''''',
19+
templateUrl: r'/bad/absolute/url.html',
20+
styles: const [r'''''', r'''''',])
1821
]
1922
});
2023
}

modules/angular2/test/transform/directive_processor/invalid_url_files/hello.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library test.transform.directive_processor.url_expression_files.hello;
1+
library test.transform.directive_processor.invalid_url_files.hello;
22

33
import 'package:angular2/angular2.dart'
44
show bootstrap, Component, Directive, View, NgElement;

modules/angular2/test/transform/directive_processor/multiple_style_urls_files/expected/hello.ng_deps.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library examples.src.hello_world.index_common_dart.ng_deps.dart;
1+
library examples.src.hello_world.multiple_style_urls_files.ng_deps.dart;
22

33
import 'hello.dart';
44
import 'package:angular2/angular2.dart'
@@ -16,6 +16,7 @@ void initReflector(reflector) {
1616
const Component(selector: 'hello-app'),
1717
const View(
1818
template: r'''{{greeting}}''',
19+
templateUrl: r'template.html',
1920
styles: const [
2021
r'''.greeting { .color: blue; }''',
2122
r'''.hello { .color: red; }''',

modules/angular2/test/transform/directive_processor/multiple_style_urls_files/hello.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library examples.src.hello_world.index_common_dart;
1+
library examples.src.hello_world.multiple_style_urls_files;
22

33
import 'package:angular2/angular2.dart'
44
show bootstrap, Component, Directive, View, NgElement;

0 commit comments

Comments
 (0)