OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library template_binding.src.mustache_tokens; | 5 library template_binding.src.mustache_tokens; |
6 | 6 |
7 import 'package:observe/observe.dart'; | 7 import 'package:observe/observe.dart'; |
8 | 8 |
9 // Dart note: this was added to decouple the parse function below from the rest | 9 // Dart note: this was added to decouple the parse function below from the rest |
10 // of template_binding. This allows using this code in command-line tools as | 10 // of template_binding. This allows using this code in command-line tools as |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 tokens.add(s.substring(lastIndex)); // TEXT | 109 tokens.add(s.substring(lastIndex)); // TEXT |
110 break; | 110 break; |
111 } | 111 } |
112 | 112 |
113 if (tokens == null) tokens = []; | 113 if (tokens == null) tokens = []; |
114 tokens.add(s.substring(lastIndex, startIndex)); // TEXT | 114 tokens.add(s.substring(lastIndex, startIndex)); // TEXT |
115 var pathString = s.substring(startIndex + 2, endIndex).trim(); | 115 var pathString = s.substring(startIndex + 2, endIndex).trim(); |
116 tokens.add(oneTime); // ONETIME? | 116 tokens.add(oneTime); // ONETIME? |
117 onlyOneTime = onlyOneTime && oneTime; | 117 onlyOneTime = onlyOneTime && oneTime; |
118 var delegateFn = fnFactory == null ? null : fnFactory(pathString); | 118 var delegateFn = fnFactory == null ? null : fnFactory(pathString); |
| 119 // Don't try to parse the expression if there's a prepareBinding function |
119 if (delegateFn == null) { | 120 if (delegateFn == null) { |
120 tokens.add(new PropertyPath(pathString)); // PATH | 121 tokens.add(new PropertyPath(pathString)); // PATH |
121 } else { | 122 } else { |
122 tokens.add(null); | 123 tokens.add(null); |
123 } | 124 } |
124 tokens.add(delegateFn); // DELEGATE_FN | 125 tokens.add(delegateFn); // DELEGATE_FN |
125 | 126 |
126 lastIndex = endIndex + 2; | 127 lastIndex = endIndex + 2; |
127 } | 128 } |
128 | 129 |
(...skipping 14 matching lines...) Expand all Loading... |
143 var newValue = new StringBuffer(getText(0)); | 144 var newValue = new StringBuffer(getText(0)); |
144 int len = this.length; | 145 int len = this.length; |
145 for (var i = 0; i < len; i++) { | 146 for (var i = 0; i < len; i++) { |
146 var value = values[i]; | 147 var value = values[i]; |
147 if (value != null) newValue.write(value); | 148 if (value != null) newValue.write(value); |
148 newValue.write(getText(i + 1)); | 149 newValue.write(getText(i + 1)); |
149 } | 150 } |
150 return newValue.toString(); | 151 return newValue.toString(); |
151 } | 152 } |
152 } | 153 } |
OLD | NEW |