Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping does not work #13

Open
jantimon opened this issue Jan 15, 2016 · 3 comments
Open

Escaping does not work #13

jantimon opened this issue Jan 15, 2016 · 3 comments

Comments

@jantimon
Copy link
Contributor

When using the escape feature of lodas/underscore templates I receive "ERROR in ReferenceError: _ is not defined"

<%- "<a href='demo'>link</a>' %>
@SpaceK33z
Copy link
Collaborator

Ah yes it assumes you use _ as a global, but that does not make much sense.

@emaphp
Copy link
Owner

emaphp commented Jan 15, 2016

Ouch, I didn't even know this feature even existed...
But here's what I noticed: when using lodash to translate a template to a function this can be found on some translations:

__e = _.escape

This can be tested by uninstalling underscore and installing lodash instead.
Weird enough, this only happens on some tests, the first and second tests on loaderTests.js. I tried several versions on lodash and the problem still persists.
I'm not a big fan of this library so I'm not capable of telling if there's a special type of configuration that could avoid this output.
These kinds of issues could be managed much better by creating another package and moving all compatibiliity code to support lodash there.

tl;dr Someone should create a lodash-template-loader

@jantimon
Copy link
Contributor Author

In my minimalistic fallback loader I just add lodash as dependency to the template:

https://github.com/ampedandwired/html-webpack-plugin/blob/feature/loaders/lib/loader.js#L25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants