Server Side JavaScript Features
Server Side JavaScript code is executed in files ending in sjs.
var today = new Date();
$res.print(today);
Embedded JavaScript files can contain any text content and JavaScript.
<% var today = new Date(); %>
<html>
<body>
Today is <%=today%>!
</body>
</html>
E4X is supported.
Easily import, manipulate and export XML data using JavaScript
Embedded JavaScript Macros
Macros are html-like contructs that make JavaScript loops and conditionals easier to implement in ".ejs" files.
See @loop and @if.
Embedded JavaScript Blocks
EJS blocks work like ".ejs" pages but can be used in JavaScript code to
return a string. All text between <ejs> and </ejs> will be returned as
if it was included from a ".ejs" page. This makes it much easier to embed
other languages like SQL or HTML in JavaScript strings.
var qry = new Myna.Query({
dataSource:"ds_name",
sql:<ejs>
select * FROM article where
id = <%=$req.data.id%>
<@if !includeDeleted>
and deleted != 1
</@if>
</ejs>
})