fix(transformer): Fix string interpolation for bindings.

Previously it did not stringify properties and used `+` instead of ` `.
This commit is contained in:
Jacob MacDonald
2015-07-01 13:20:12 -07:00
parent 582551bea9
commit 311b47720b
12 changed files with 62 additions and 22 deletions

View File

@ -111,4 +111,3 @@ Map<String, String> _createEventsMap(NgDeps ngDeps) {
});
return bindMap;
}

View File

@ -6,8 +6,8 @@ import 'package:angular2/src/transform/common/logging.dart';
/// Visitor responsible for crawling the "annotations" value in a
/// `registerType` call and pulling out the properties of any "bind"
/// values found.
class ExtractNamedExpressionVisitor extends Object with
RecursiveAstVisitor<Object> {
class ExtractNamedExpressionVisitor extends Object
with RecursiveAstVisitor<Object> {
final ConstantEvaluator _evaluator = new ConstantEvaluator();
final List<String> bindConfig = [];
final String nameToExtract;

View File

@ -61,8 +61,7 @@ class TransformerOptions {
MirrorMode mirrorMode: MirrorMode.none, bool initReflector: true,
List<AnnotationDescriptor> customAnnotationDescriptors: const [],
int optimizationPhases: DEFAULT_OPTIMIZATION_PHASES,
bool inlineViews: true,
bool generateChangeDetectors: true}) {
bool inlineViews: true, bool generateChangeDetectors: true}) {
if (reflectionEntryPoints == null || reflectionEntryPoints.isEmpty) {
reflectionEntryPoints = entryPoints;
}

View File

@ -16,8 +16,9 @@ class Codegen {
Codegen(String reflectionEntryPointPath, Iterable<String> newEntryPointPaths,
{String prefix})
: this.prefix = prefix == null ? _PREFIX_BASE : prefix,
importUris = newEntryPointPaths.map((p) =>
path.relative(p, from: path.dirname(reflectionEntryPointPath)).replaceAll('\\', '/')) {
importUris = newEntryPointPaths.map((p) => path
.relative(p, from: path.dirname(reflectionEntryPointPath))
.replaceAll('\\', '/')) {
if (this.prefix.isEmpty) throw new ArgumentError.value('(empty)', 'prefix');
}

View File

@ -113,7 +113,9 @@ class Rewriter {
String _importDebugReflectionCapabilities(ImportDirective node) {
var uri = '${node.uri}';
uri = path.join(path.dirname(uri), 'debug_${path.basename(uri)}').replaceAll('\\', '/');
uri = path
.join(path.dirname(uri), 'debug_${path.basename(uri)}')
.replaceAll('\\', '/');
var asClause = node.prefix != null ? ' as ${node.prefix}' : '';
return 'import $uri$asClause;';
}

View File

@ -424,7 +424,9 @@ class _CodegenState {
String _genInterpolation(ProtoRecord r) {
var res = new StringBuffer();
for (var i = 0; i < r.args.length; ++i) {
res.write('${JSON.encode(r.fixedArgs[i])} + ${_localNames[r.args[i]]} +');
var name = _localNames[r.args[i]];
res.write(
'${JSON.encode(r.fixedArgs[i])} "\$\{$name == null ? "" : $name\}" ');
}
res.write(JSON.encode(r.fixedArgs[r.args.length]));
return '$res';