Skip to content

Instantly share code, notes, and snippets.

@rmcauley
Created February 23, 2015 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmcauley/65ea9fe82827cb205c34 to your computer and use it in GitHub Desktop.
Save rmcauley/65ea9fe82827cb205c34 to your computer and use it in GitHub Desktop.
parser = RainwaveParser("main")
parser.feed('<html><head><title>Test</title></head>'
'<body>'
'<h1 class="hello" bind="h1">Parse me!</h1>'
'{{#each song }}'
' <div class="song" class="{{ crap }}">{{ title }}</div>'
'{{/each}}'
'</body></html>'
)
parser.close()
----------
function main(context) {
var _to_return = {};
var v1 = document.createElement('html');
to_return.root = v1;
var v2 = document.createElement('head');
v1.appendChild(v2);
var v3 = document.createElement('title');
v2.appendChild(v3);
v3.textContent = "Test";
var v4 = document.createElement('body');
v1.appendChild(v4);
var v5 = document.createElement('h1');
v4.appendChild(v5);
v5.setAttribute('class', "hello");
_to_return.h1 = v5;
v5.textContent = "Parse me!";
var v6 = function(context) {
var v7 = document.createElement('div');
v4.appendChild(v7);
v7.setAttribute('class', "song");
v7.setAttribute('class', context.crap);
v7.textContent = context.title;
};
for (var i = 0; i < context.song.length; i++) {
v6(context.song[i]);
}
return _to_return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment