phnq_ejs
Version:
Embedded JavaScript templating tool
41 lines (39 loc) • 606 B
Plain Text
it should correctly invoke a function with a body
==========
{
_locals:
{
withBodyNoArgs: function(fn)
{
var x = 10;
var y = 5;
var buf = [];
fn(buf);
return "<<< " + (x+y) + ", " + buf.join("").trim() + " >>>";
},
withBodyArgs: function(x, y, fn)
{
var buf = [];
fn(buf);
return "<<< " + (x+y) + ", " + buf.join("").trim() + " >>>";
},
add: function(x, y)
{
return x+y;
}
}
}
==========
ONE
<%=withBodyNoArgs(function(){ %>
YOP
<%});%>
<%=withBodyArgs(10, 20, function(){ %>
{add 1, 2 / }
<%});%>
THREE
==========
ONE
<<< 15, YOP >>>
<<< 30, 3 >>>
THREE