Jemplate

 view release on metacpan or  search on metacpan

tests/js/jemplate.js  view on Meta::CPAN

    catch(e) {
        throw(context.set_error(e, output));
    }
    stash.set('loop', oldloop);
})();

    }
    catch(e) {
        var error = context.set_error(e, output);
        throw(error);
    }

    return output;
}

Jemplate.templateMap['foo'] = function(context) {
    if (! context) throw('Jemplate function called without context\n');
    var stash = context.stash;
    var output = '';

    try {
output += 'I <3 Sushi\n';
    }
    catch(e) {
        var error = context.set_error(e, output);
        throw(error);
    }

    return output;
}

Jemplate.templateMap['directives2.html'] = function(context) {
    if (! context) throw('Jemplate function called without context\n');
    var stash = context.stash;
    var output = '';

    try {
//line 1 "directives2.html"
stash.set('num', 4);
//line 2 "directives2.html"
stash.set('array', [ ]);
//line 6 "directives2.html"
    
// WHILE
var failsafe = 1000;
while (--failsafe && (stash.get('num') < 7)) {
//line 4 "directives2.html"
if (stash.get('num') % 2) {
//line 4 "directives2.html"
stash.get(['array', 0, 'push', [ 'Odd' ]]);
}
else {
//line 4 "directives2.html"
stash.get(['array', 0, 'push', [ 'Even' ]]);
}

//line 5 "directives2.html"
stash.set('num', stash.get('num') + 1);
}
if (! failsafe)
    throw("WHILE loop terminated (> 1000 iterations)\n")

//line 7 "directives2.html"
output += stash.get(['array', 0, 'join', [ '***' ]]);
output += '\n';
    }
    catch(e) {
        var error = context.set_error(e, output);
        throw(error);
    }

    return output;
}

Jemplate.templateMap['directives3.html'] = function(context) {
    if (! context) throw('Jemplate function called without context\n');
    var stash = context.stash;
    var output = '';

    try {
//line 3 "directives3.html"
stash.set("obj", {"key1": "val1", "key2": "val2"});
output += 'Key1: ';
//line 4 "directives3.html"
output += stash.get(['obj', 0, 'key1', 0]);
output += '\nKey2: ';
//line 5 "directives3.html"
output += stash.get(['obj', 0, 'key2', 0]);
output += '\n';
    }
    catch(e) {
        var error = context.set_error(e, output);
        throw(error);
    }

    return output;
}

Jemplate.templateMap['directives4.html'] = function(context) {
    if (! context) throw('Jemplate function called without context\n');
    var stash = context.stash;
    var output = '';

    try {
//line 3 "directives4.html"
stash.set("obj", {"key1": "val1", "key2": "val2"});
//line 6 "directives4.html"

// FOREACH 
(function() {
    var list = stash.get('obj');
    list = new Jemplate.Iterator(list);
    var retval = list.get_first();
    var value = retval[0];
    var done = retval[1];
    var oldloop;
    try { oldloop = stash.get('loop') } finally {}
    stash.set('loop', list);
    try {
        while (! done) {
            stash.data['key'] = value;



( run in 0.604 second using v1.01-cache-2.11-cpan-71847e10f99 )