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

Unified Diff: pkg/template_binding/lib/src/mustache_tokens.dart

Issue 211393006: Enables codegen support in polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « pkg/template_binding/CHANGELOG.md ('k') | pkg/template_binding/lib/src/template_iterator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/template_binding/lib/src/mustache_tokens.dart
diff --git a/pkg/template_binding/lib/src/mustache_tokens.dart b/pkg/template_binding/lib/src/mustache_tokens.dart
index be84d26205cba07597410dc02446e1604e4f646d..7478d923966758916efacac1264bceaa19a0c46c 100644
--- a/pkg/template_binding/lib/src/mustache_tokens.dart
+++ b/pkg/template_binding/lib/src/mustache_tokens.dart
@@ -5,7 +5,11 @@
library template_binding.src.mustache_tokens;
import 'package:observe/observe.dart';
-import 'package:template_binding/template_binding.dart';
+
+// Dart note: this was added to decouple the parse function below from the rest
+// of template_binding. This allows using this code in command-line tools as
+// well.
+typedef Function DelegateFunctionFactory(String pathString);
/**
* Represents a set of parsed tokens from a {{ mustache binding expression }}.
@@ -74,8 +78,7 @@ class MustacheTokens {
*
* Returns null if there are no matches. Otherwise returns the parsed tokens.
*/
- static MustacheTokens parse(String s, String name, node,
- BindingDelegate delegate) {
+ static MustacheTokens parse(String s, [DelegateFunctionFactory fnFactory]) {
if (s == null || s.isEmpty) return null;
var tokens = null;
@@ -112,15 +115,18 @@ class MustacheTokens {
var pathString = s.substring(startIndex + 2, endIndex).trim();
tokens.add(oneTime); // ONETIME?
onlyOneTime = onlyOneTime && oneTime;
- tokens.add(new PropertyPath(pathString)); // PATH
- var delegateFn = delegate == null ? null :
- delegate.prepareBinding(pathString, name, node);
- tokens.add(delegateFn);
+ var delegateFn = fnFactory == null ? null : fnFactory(pathString);
+ if (delegateFn == null) {
+ tokens.add(new PropertyPath(pathString)); // PATH
+ } else {
+ tokens.add(null);
+ }
+ tokens.add(delegateFn); // DELEGATE_FN
lastIndex = endIndex + 2;
}
- if (lastIndex == length) tokens.add('');
+ if (lastIndex == length) tokens.add(''); // TEXT
return new MustacheTokens._(tokens, onlyOneTime);
}
« no previous file with comments | « pkg/template_binding/CHANGELOG.md ('k') | pkg/template_binding/lib/src/template_iterator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698