Skip to content

Commit

Permalink
More accurate import of escape
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Apr 11, 2016
1 parent 8dc16fb commit d66825f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ export default function( options = {} ) {

const tpl = template( code, templateOptions );

const source = tpl.source;

const intro = /__e = _.escape/.test(source) ?
`
import escape from 'lodash-es/escape';
var _ = { escape: escape };
`:
'';
let hasEscape = false;
const source = tpl.source.replace(/__e = _.escape/, function() {
hasEscape = true;
return '__e = escape';
});

const intro = hasEscape ? "import escape from 'lodash-es/escape'" : "";

return `
${intro}
Expand Down

0 comments on commit d66825f

Please sign in to comment.