Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: lib/src/emitters.dart

Issue 13592003: add support for template repeat (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: feedback Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/analyzer.dart ('k') | lib/src/html_cleaner.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/emitters.dart
diff --git a/lib/src/emitters.dart b/lib/src/emitters.dart
index 90426f5d00e3bed3d7ba51106099197668b27c07..fff1673995038f6a328469afb4ad96fd32a61344 100644
--- a/lib/src/emitters.dart
+++ b/lib/src/emitters.dart
@@ -90,7 +90,7 @@ void emitInitializations(ElementInfo info,
printer.add(childrenPrinter);
- if (info.childrenCreatedInCode && !info.hasIterate && !info.hasIfCondition) {
+ if (info.childrenCreatedInCode && !info.hasLoop && !info.hasCondition) {
_emitAddNodes(printer, context.statics, info.children, '$id.nodes');
}
}
@@ -334,21 +334,25 @@ void emitConditional(TemplateInfo info, CodePrinter printer,
/**
* Emits code for template lists like `<template iterate='item in items'>` or
- * `<td template iterate='item in items'>`.
+ * `<td template repeat='item in items'>`.
*/
void emitLoop(TemplateInfo info, CodePrinter printer, Context childContext) {
var id = info.identifier;
var items = info.loopItems;
var loopVar = info.loopVariable;
- printer..addLine('__t.loop($id, () => $items, ($loopVar, __t) {',
+
+ var suffix = '';
+ // TODO(jmesserly): remove this functionality after a grace period.
+ if (!info.isTemplateElement && !info.isRepeat) suffix = 'IterateAttr';
+
+ printer..addLine('__t.loop$suffix($id, () => $items, ($loopVar, __t) {',
span: info.node.sourceSpan)
..indent += 1
..add(childContext.declarations)
..add(childContext.printer)
..indent -= 1;
_emitAddNodes(printer, childContext.statics, info.children, '__t');
- printer..addLine(info.isTemplateElement
- ? '});' : '}, isTemplateElement: false);');
+ printer.addLine('});');
}
@@ -383,10 +387,10 @@ class RecursiveEmitter extends InfoVisitor {
emitComponentCreation(info, _context.printer);
var childContext = null;
- if (info.hasIfCondition) {
+ if (info.hasCondition) {
childContext = new Context(statics: _context.statics, indent: indent + 1);
emitConditional(info, _context.printer, childContext);
- } else if (info.hasIterate) {
+ } else if (info.hasLoop) {
childContext = new Context(statics: _context.statics, indent: indent + 1);
emitLoop(info, _context.printer, childContext);
} else {
« no previous file with comments | « lib/src/analyzer.dart ('k') | lib/src/html_cleaner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698