Skip to content

Commit

Permalink
Merge pull request #458 from EB-Forks/feat/disable-legacy-include-dir…
Browse files Browse the repository at this point in the history
…ective

This is great. We can introduce as an opt defaulting to on, then default to off, then remove this thing completely.
  • Loading branch information
mde authored Sep 8, 2019
2 parents 3de0ade + e3d128b commit b364cc3
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 b364cc3

Please sign in to comment.