Skip to content

Commit

Permalink
feat: Allow disabling legacy include preprocessor directives
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Sep 6, 2019
1 parent 3de0ade commit e3d128b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/jsdoc/options.jsdoc
Expand Up @@ -71,6 +71,14 @@
* Whether or not to create an async function instead of a regular function.
* This requires language support.
*
* @property {boolean} [legacyInclude=true]
* Whether to enable legacy preprocessor include directives.
*
* **Example:**
* ```ejs
* <%- include foo %>
* ```
*
* @static
* @global
*/
3 changes: 2 additions & 1 deletion lib/ejs.js
Expand Up @@ -526,6 +526,7 @@ function Template(text, opts) {
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
options.views = opts.views;
options.async = opts.async;
options.legacyInclude = typeof opts.legacyInclude != 'undefined' ? !!opts.legacyInclude : true;

if (options.strict) {
options._with = false;
Expand Down Expand Up @@ -711,7 +712,7 @@ Template.prototype = {
}
}
// HACK: backward-compat `include` preprocessor directives
if ((include = line.match(/^\s*include\s+(\S+)/))) {
if (opts.legacyInclude && (include = line.match(/^\s*include\s+(\S+)/))) {
opening = matches[index - 1];
// Must be in EVAL or RAW mode
if (opening && (opening == o + d || opening == o + d + '-' || opening == o + d + '_')) {
Expand Down

0 comments on commit e3d128b

Please sign in to comment.