Build 0.6.1.
Showing
4 changed files
with
21 additions
and
17 deletions
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "name": "rivets", | 2 | "name": "rivets", |
3 | "repo": "mikeric/rivets", | 3 | "repo": "mikeric/rivets", |
4 | "description": "Declarative data binding + templating solution.", | 4 | "description": "Declarative data binding + templating solution.", |
5 | "version": "0.6.0", | 5 | "version": "0.6.1", |
6 | "keywords": ["data binding", "templating"], | 6 | "keywords": ["data binding", "templating"], |
7 | "scripts": ["dist/rivets.js"], | 7 | "scripts": ["dist/rivets.js"], |
8 | "main": "dist/rivets.js", | 8 | "main": "dist/rivets.js", | ... | ... |
1 | // Rivets.js | 1 | // Rivets.js |
2 | // version: 0.6.0 | 2 | // version: 0.6.1 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
... | @@ -174,28 +174,22 @@ | ... | @@ -174,28 +174,22 @@ |
174 | return _this.bindings.push(new Rivets[binding](_this, node, type, keypath, options)); | 174 | return _this.bindings.push(new Rivets[binding](_this, node, type, keypath, options)); |
175 | }; | 175 | }; |
176 | parse = function(node) { | 176 | parse = function(node) { |
177 | var attribute, attributes, binder, childNode, delimiters, identifier, n, parser, regexp, restTokens, startToken, text, token, tokens, type, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _results; | 177 | var attribute, attributes, binder, childNode, delimiters, identifier, n, parser, regexp, text, token, tokens, type, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _results; |
178 | if (__indexOf.call(skipNodes, node) < 0) { | 178 | if (__indexOf.call(skipNodes, node) < 0) { |
179 | if (node.nodeType === Node.TEXT_NODE) { | 179 | if (node.nodeType === Node.TEXT_NODE) { |
180 | parser = Rivets.TextTemplateParser; | 180 | parser = Rivets.TextTemplateParser; |
181 | if (delimiters = _this.config.templateDelimiters) { | 181 | if (delimiters = _this.config.templateDelimiters) { |
182 | if ((tokens = parser.parse(node.data, delimiters)).length) { | 182 | if ((tokens = parser.parse(node.data, delimiters)).length) { |
183 | if (!(tokens.length === 1 && tokens[0].type === parser.types.text)) { | 183 | if (!(tokens.length === 1 && tokens[0].type === parser.types.text)) { |
184 | startToken = tokens[0], restTokens = 2 <= tokens.length ? __slice.call(tokens, 1) : []; | 184 | for (_i = 0, _len = tokens.length; _i < _len; _i++) { |
185 | node.data = startToken.value; | 185 | token = tokens[_i]; |
186 | if (startToken.type === 0) { | ||
187 | node.data = startToken.value; | ||
188 | } else { | ||
189 | buildBinding('TextBinding', node, null, startToken.value); | ||
190 | } | ||
191 | for (_i = 0, _len = restTokens.length; _i < _len; _i++) { | ||
192 | token = restTokens[_i]; | ||
193 | text = document.createTextNode(token.value); | 186 | text = document.createTextNode(token.value); |
194 | node.parentNode.appendChild(text); | 187 | node.parentNode.insertBefore(text, node); |
195 | if (token.type === 1) { | 188 | if (token.type === 1) { |
196 | buildBinding('TextBinding', text, null, token.value); | 189 | buildBinding('TextBinding', text, null, token.value); |
197 | } | 190 | } |
198 | } | 191 | } |
192 | node.parentNode.removeChild(node); | ||
199 | } | 193 | } |
200 | } | 194 | } |
201 | } | 195 | } |
... | @@ -240,7 +234,16 @@ | ... | @@ -240,7 +234,16 @@ |
240 | } | 234 | } |
241 | } | 235 | } |
242 | } | 236 | } |
243 | _ref4 = node.childNodes; | 237 | _ref4 = (function() { |
238 | var _len4, _n, _ref4, _results1; | ||
239 | _ref4 = node.childNodes; | ||
240 | _results1 = []; | ||
241 | for (_n = 0, _len4 = _ref4.length; _n < _len4; _n++) { | ||
242 | n = _ref4[_n]; | ||
243 | _results1.push(n); | ||
244 | } | ||
245 | return _results1; | ||
246 | })(); | ||
244 | _results = []; | 247 | _results = []; |
245 | for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) { | 248 | for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) { |
246 | childNode = _ref4[_m]; | 249 | childNode = _ref4[_m]; |
... | @@ -668,9 +671,10 @@ | ... | @@ -668,9 +671,10 @@ |
668 | }; | 671 | }; |
669 | 672 | ||
670 | TextTemplateParser.parse = function(template, delimiters) { | 673 | TextTemplateParser.parse = function(template, delimiters) { |
671 | var index, lastIndex, lastToken, length, substring, tokens, value; | 674 | var delimiterOffset, index, lastIndex, lastToken, length, substring, tokens, value; |
672 | tokens = []; | 675 | tokens = []; |
673 | length = template.length; | 676 | length = template.length; |
677 | delimiterOffset = delimiters[1].length; | ||
674 | index = 0; | 678 | index = 0; |
675 | lastIndex = 0; | 679 | lastIndex = 0; |
676 | while (lastIndex < length) { | 680 | while (lastIndex < length) { |
... | @@ -708,7 +712,7 @@ | ... | @@ -708,7 +712,7 @@ |
708 | type: this.types.binding, | 712 | type: this.types.binding, |
709 | value: value | 713 | value: value |
710 | }); | 714 | }); |
711 | lastIndex = index + 2; | 715 | lastIndex = index + delimiterOffset; |
712 | } | 716 | } |
713 | } | 717 | } |
714 | return tokens; | 718 | return tokens; | ... | ... |
This diff is collapsed.
Click to expand it.
1 | { | 1 | { |
2 | "name": "rivets", | 2 | "name": "rivets", |
3 | "description": "Declarative data binding + templating solution.", | 3 | "description": "Declarative data binding + templating solution.", |
4 | "version": "0.6.0", | 4 | "version": "0.6.1", |
5 | "author": "Michael Richards", | 5 | "author": "Michael Richards", |
6 | "url": "http://rivetsjs.com", | 6 | "url": "http://rivetsjs.com", |
7 | "main": "./dist/rivets.js", | 7 | "main": "./dist/rivets.js", | ... | ... |
-
Please register or sign in to post a comment