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

Unified Diff: utils/template/htmltree.dart

Issue 9728009: Template bug fixes and new features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Undid css.status change Created 8 years, 9 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 | « utils/template/codegen.dart ('k') | utils/template/parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/template/htmltree.dart
diff --git a/utils/template/htmltree.dart b/utils/template/htmltree.dart
index af75f14748deec4be7689e1c1467f0234cd8d47b..385340049505b2c80e0b33d90ac367babd340230 100644
--- a/utils/template/htmltree.dart
+++ b/utils/template/htmltree.dart
@@ -209,26 +209,45 @@ class TemplateExpression extends ASTNode {
class TemplateEachCommand extends ASTNode {
String listName;
+ String loopItem;
TemplateDocument documentFragment;
- TemplateEachCommand(this.listName, this.documentFragment, SourceSpan span):
- super(span);
+ TemplateEachCommand(this.listName, this.loopItem, this.documentFragment,
+ SourceSpan span): super(span);
+
+ bool get hasLoopItem() => loopItem != null;
+ String get loopNameOptional() => hasLoopItem ? " ${loopItem}" : "";
visit(TreeVisitor visitor) => visitor.visitTemplateEachCommand(this);
- String toString() => "\$\{#each ${listName}}";
+ String toString() => "\$\{#each ${listName}${loopNameOptional}}";
}
class TemplateWithCommand extends ASTNode {
String objectName;
+ String blockItem;
TemplateDocument documentFragment;
- TemplateWithCommand(this.objectName, this.documentFragment, SourceSpan span):
- super(span);
+ TemplateWithCommand(this.objectName, this.blockItem, this.documentFragment,
+ SourceSpan span): super(span);
+
+ bool get hasBlockItem() => blockItem != null;
+ String get blockNameOptional() => hasBlockItem ? " ${blockItem}" : "";
visit(TreeVisitor visitor) => visitor.visitTemplateWithCommand(this);
- String toString() => "\$\{#with ${objectName}}";
+ String toString() => "\$\{#with ${objectName}${blockNameOptional}}";
+}
+
+class TemplateCall extends ASTNode {
+ String toCall;
+ String params;
+
+ TemplateCall(this.toCall, this.params, SourceSpan span): super(span);
+
+ visit(TreeVisitor visitor) => visitor.visitTemplateCall(this);
+
+ String toString() => "\$\{#${toCall}${params}}";
}
interface TreeVisitor {
@@ -246,6 +265,7 @@ interface TreeVisitor {
void visitTemplateExpression(TemplateExpression node);
void visitTemplateEachCommand(TemplateEachCommand node);
void visitTemplateWithCommand(TemplateWithCommand node);
+ void visitTemplateCall(TemplateCall node);
}
class TreePrinter implements TreeVisitor {
@@ -344,5 +364,12 @@ class TreePrinter implements TreeVisitor {
output.writeValue('object', node.objectName);
visitTemplateDocument(node.documentFragment);
}
+
+ void visitTemplateCall(TemplateCall node) {
+ output.heading('#call template', node.span);
+ output.writeValue('templateToCall', node.toCall);
+ output.writeValue('params', node.params);
+ }
+
}
« no previous file with comments | « utils/template/codegen.dart ('k') | utils/template/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698