Skip to content

Commit

Permalink
refactor(tag): remove escape
Browse files Browse the repository at this point in the history
'{' & '}' already escaped in backtick code filter
  • Loading branch information
SukkaW committed Mar 6, 2020
1 parent 1b0819a commit 1bc7e78
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions lib/extend/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const stripIndent = require('strip-indent');
const { cyan } = require('chalk');
const nunjucks = require('nunjucks');
const Promise = require('bluebird');
const placeholder = '\uFFFC';
const rPlaceholder = /(?:<|&lt;)!--\uFFFC(\d+)--(?:>|&gt;)/g;

class NunjucksTag {
constructor(name, fn) {
Expand Down Expand Up @@ -228,15 +226,8 @@ class Tag {
options = {};
}

const cache = [];

const escapeContent = str => `<!--${placeholder}${cache.push(str) - 1}-->`;

str = str.replace(/<pre><code.*>[\s\S]*?<\/code><\/pre>/gm, escapeContent);

return Promise.fromCallback(cb => { this.env.renderString(str, options, cb); })
.catch(err => Promise.reject(formatNunjucksError(err, str)))
.then(result => result.replace(rPlaceholder, (_, index) => cache[index]));
.catch(err => Promise.reject(formatNunjucksError(err, str)));
}
}

Expand Down

0 comments on commit 1bc7e78

Please sign in to comment.