Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function foo(str, context) {
- return str.replace(/\{(\w+(?:\.\w+)*)\}/g, function(match, name) {
- var keys = name.split('.'), k, v = context;
- while ( k = keys.shift() ) {
- if (v[k] == undefined) {
- v = '';
- break;
- }
- v = v[k];
- }
- return v;
- });
- }
- function parse(str) {
- var re = /\{\{(.?)\}\}|\{%(.*?)%\}/g;
- }
- template = '<ul class="comments">{% for comment in comments %}<li><a href="{{comment.author_link}}">{{comment.author_name}}</a>, <time>{{comment.datetime}}</time><p>{{comment.text}}</p></li>{% /for %}</ul>';
Advertisement
Add Comment
Please, Sign In to add comment