feat(transformers): inline styleUrls to view directive
While creating the ng_deps.dart file for a view inline the styleUrls attribute. This copies the pattern used for templateUrl, aleviating the need to make an XHR request for those resources. closes #2566
This commit is contained in:
@ -259,13 +259,31 @@ class AnnotationsTransformVisitor extends ToSourceVisitor {
|
||||
}
|
||||
var keyString = '${node.name.label}';
|
||||
if (keyString == 'templateUrl') {
|
||||
// Inline the templateUrl
|
||||
var url = node.expression.accept(_evaluator);
|
||||
if (url is String) {
|
||||
writer.print("template: r'''");
|
||||
writer.asyncPrint(_xhr.get(url));
|
||||
writer.print("'''");
|
||||
return null;
|
||||
} else {
|
||||
logger.warning('template url is not a String $url');
|
||||
}
|
||||
} else if (keyString == 'styleUrls') {
|
||||
// Inline the styleUrls
|
||||
var urls = node.expression.accept(_evaluator);
|
||||
writer.print('styles: const [');
|
||||
for (var url in urls) {
|
||||
if (url is String) {
|
||||
writer.print("r'''");
|
||||
writer.asyncPrint(_xhr.get(url));
|
||||
writer.print("''', ");
|
||||
} else {
|
||||
logger.warning('style url is not a String ${url}');
|
||||
}
|
||||
}
|
||||
writer.print(']');
|
||||
return null;
|
||||
}
|
||||
return super.visitNamedExpression(node);
|
||||
}
|
||||
|
Reference in New Issue
Block a user