Chromium Code Reviews| 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..071c69d327b1789efee70793d72a5417fd8a5555 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 tempalte_binding. This allows using this code in command-line tools as |
|
Jennifer Messerly
2014/03/28 21:48:35
typo: template_binding
Siggi Cherem (dart-lang)
2014/03/28 22:08:48
Done.
|
| +// 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) { |
|
Siggi Cherem (dart-lang)
2014/03/28 01:04:26
this was a patch Justin did upstream, I wanted to
|
| + 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); |
| } |