diff --git a/docs/jsdoc/options.jsdoc b/docs/jsdoc/options.jsdoc index 5b6fdb18..2edb1d5c 100644 --- a/docs/jsdoc/options.jsdoc +++ b/docs/jsdoc/options.jsdoc @@ -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 */ diff --git a/lib/ejs.js b/lib/ejs.js index c65354c8..b011424d 100755 --- a/lib/ejs.js +++ b/lib/ejs.js @@ -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; @@ -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 + '_')) {