new EJS EJS.startTag; // '<%'; EJS.endTag; // '%>'; Terms: Unclosed logical blocks: if, else, for, ... blocks; if( ??? ) { ... } Unclosed functional blocks: someFunction( ... ) For code examples the default <% and %> start and end tags are used, however these can be customized at compile time. Full templates have the following intro code added: function() { var _buf = []; And the following outro code added: return _buf.join(''); }; Compiled syntax translations. -- Simple code blocks abc<% fn(); %>123 _buf.push( 'abc' ); fn(); _buf.push( '123' ); -- Echoing code blocks abc<%= fn(); %>123 _buf.push( 'abc' ); _buf.push( fn() ); _buf.push( '123' ); -- Echoing code blocks with filters abc<%h= fn(); %>123 _buf.push( 'abc' ); _buf.push( EJS.filters['h']( fn() ) ); _buf.push( '123' ); -- Unclosed logical blocks abc<% if( true ) { %>xyz<% } %>123 _buf.push( 'abc' ); if( true ) { _buf.push( 'xyz' ); } _buf.push( '123' ); -- Unclosed functional blocks abc<% fn( %>xyz<% ); %>123 _buf.push( 'abc' ); fn( function() { _buf.push( 'xyz' ); } ); _buf.push( '123' ); -- Echoing unclosed functional blocks abc<%= fn( %>xyz<% ); %>123 _buf.push( 'abc' ); _buf.push( fn( function() { var _buf = []; _buf.push( 'xyz' ); return _buf; } ) ); _buf.push( '123' ); Logical blocks may not be used directly in echoed syntax. ie: you can't do this: abc<%= if( true ) { foo(); } %> %>'s are dominant over //'s, if a // ... %> is found where a %> follows a // on the same line then all text from the // to the %> is discarded /*'s are dominant over %>'s, if a /* is found in open code the comment runs on until the next */ and discarded. So <% /* %> */ %> will discard the %> in the middle instead of considering it the end of the code mode. Strings are dominant over %>'s, just like a /* a %> inside of a string will not be considered the end of a block. Markup blocks inside of object and array blocks are treated like "Echoing unclosed functional blocks" Ending ;'s in code are stripped and EJS adds it's own in the proper place, see "Echoing code blocks" to see why this is necessary.