Jemplate
view release on metacpan or search on metacpan
examples/js/features.js view on Meta::CPAN
output += '\n<h3>';
//line 11 "body.html"
output += stash.get('i');
output += '</h3>\n';
output += '\n';
//line 13 "body.html"
stash.set('i', stash.get('i') - 1);
output += '\n';
}
if (! failsafe)
throw("WHILE loop terminated (> 1000 iterations)\n")
output += '\n\n';
//line 18 "body.html"
// WRAPPER
output += (function() {
var output = '';
output += '\nLife is good\n';;
var files = new Array('wrapper2.html', 'wrapper.html');
for (var i = 0; i < files.length; i++) {
$label ||= 'LOOP';
return <<EOF;
do {
my \$_tt_failsafe = $WHILE_MAX;
$label:
while (--\$_tt_failsafe && ($expr)) {
$block
}
die "WHILE loop terminated (> $WHILE_MAX iterations)\\n"
unless \$_tt_failsafe;
};
EOF
}
sub switch {
my ($self, $expr, $case) = @_;
my @case = @$case;
my ($class, $expr, $block) = @_;
return <<EOF;
// WHILE
var failsafe = $WHILE_MAX;
while (--failsafe && ($expr)) {
$block
}
if (! failsafe)
throw("WHILE loop terminated (> $WHILE_MAX iterations)\\n")
EOF
}
sub javascript {
my ( $class, $javascript ) = @_;
return $javascript;
}
sub no_javascript {
my ( $class ) = @_;
lib/Jemplate/Directive.pm view on Meta::CPAN
my ($class, $expr, $block) = @_;
return <<EOF;
// WHILE
var failsafe = $WHILE_MAX;
while (--failsafe && ($expr)) {
$block
}
if (! failsafe)
throw("WHILE loop terminated (> $WHILE_MAX iterations)\\n")
EOF
}
#------------------------------------------------------------------------
# javascript($script) [% JAVASCRIPT %]
# ...
# [% END %]
#------------------------------------------------------------------------
sub javascript {
my ( $class, $javascript ) = @_;
return output;
}
else {
//line X "(unknown template)"
throw('Jemplate.STOP\n' + output);
}
output += ' Bar';
}
if (! failsafe)
throw("WHILE loop terminated (> 1000 iterations)\n")
=== WHILE/NEXT/LAST Directives
--- tt
Foo
[%- WHILE (foo == 'bar') -%]
[%- IF 1 == 2 -%]
[%- NEXT -%]
[%- ELSE -%]
[%- LAST -%]
[%- END -%]
}
else {
//line X "(unknown template)"
break;
}
output += ' Bar';
}
if (! failsafe)
throw("WHILE loop terminated (> 1000 iterations)\n")
tests/js/jemplate.js view on Meta::CPAN
}
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);
}
( run in 1.805 second using v1.01-cache-2.11-cpan-71847e10f99 )