finish text parser

This commit is contained in:
Evan You 2013-08-08 17:37:54 -04:00
parent 5541b971ed
commit b5f0227186
3 changed files with 21 additions and 10 deletions

View File

@ -60,9 +60,7 @@
<!-- footer controls -->
<footer id="footer" sd-show="total">
<span id="todo-count">
<strong sd-text="remaining"></strong>
<span sd-text="itemLabel"></span>
left
<strong sd-text="remaining"></strong> {{itemLabel}} left
</span>
<ul id="filters">
<li><a href="#/all" data-filter="all" sd-on="click:setFilter">All</a></li>
@ -70,7 +68,7 @@
<li><a href="#/completed" data-filter="completed" sd-on="click:setFilter">Completed</a></li>
</ul>
<button id="clear-completed" sd-on="click:removeCompleted">
Remove Completed (<span sd-text="completed"></span>)
Remove Completed ({{completed}})
</button>
</footer>

View File

@ -153,7 +153,23 @@ Seed.prototype._compileNode = function (node, root) {
* Compile a text node
*/
Seed.prototype._compileTextNode = function (node) {
return TextParser.parse(node)
var tokens = TextParser.parse(node)
if (!tokens) return
var seed = this
tokens.forEach(function (token) {
var el = document.createTextNode()
if (token.key) {
var directive = Directive.parse(config.prefix + '-text', token.key)
if (directive) {
directive.el = el
seed._bind(directive)
}
} else {
el.nodeValue = token
}
node.parentNode.insertBefore(el, node)
})
node.parentNode.removeChild(node)
}
/*

View File

@ -1,14 +1,11 @@
var config = require('./config')
var ESCAPE_RE = /[-.*+?^${}()|[\]\/\\]/g,
var config = require('./config'),
ESCAPE_RE = /[-.*+?^${}()|[\]\/\\]/g,
BINDING_RE = undefined
function escapeRegex (val) {
return val.replace(ESCAPE_RE, '\\$&')
}
"this is {{cool}} hahah {{todo.but}} 123 {{total}}"
module.exports = {
/*