can-view-parser
Parse HTML and mustache tokens.
parse(html, handler, [returnIntermediate])
Parse an html string:
var parser = require("can-view-parser");
var html = '<h1><span bob="phillips"></span><span bob="meyers"></span>' +
'</h1>';
var bobs = {};
var curAttr;
parser(html, {
attrStart: function(attrName){
curAttr = attrName;
},
attrValue: function(value){
bobs[curAttr] = value;
}
});
for(var first in bobs) {
var last = bobs[first];
console.log("Hello", first, last);
}
Parameters
- html
{String|Object}
:A mustache and html string to parse or an intermediate object the represents a previous parsing.
- handler
{ParseHandler}
:An object of callbacks.
- returnIntermediate
{Boolean}
:If true, returns a JS object representation of the parsing.