sindresorhus / gulp-template

Render/precompile Lodash templates
MIT License
289 stars 77 forks source link

lodash template throws: ReferenceError: asset is not defined #8

Closed tooreht closed 10 years ago

tooreht commented 10 years ago

I have this statement in a template:

jQuery.getScript("${asset.get("<%= hitbox %>")}");

This ${asset.get()} seems to confuse the template parsing and throws:

events.js:72
        throw er; // Unhandled 'error' event
              ^
ReferenceError: asset is not defined
    at eval (eval at template (node_modules/gulp-template/node_modules/lodash/dist/lodash.js:6305:22), <anonymous>:7:10)
    at template (node_modules/gulp-template/node_modules/lodash/dist/lodash.js:6311:16)
    at Transform._transform (node_modules/gulp-template/index.js:19:31)
    at Transform._read (node_modules/gulp-template/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at Transform._write (node_modules/gulp-template/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (node_modules/gulp-template/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:238:10)
    at writeOrBuffer (node_modules/gulp-template/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:228:5)
    at Transform.Writable.write (node_modules/gulp-template/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:195:11)
    at write (node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:605:24)
    at flow (node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:614:7)

It runs flawlessly with grunt-template

sindresorhus commented 10 years ago

grunt-template is using a much older version of lodash.

This plugin just passes your template to lodash.template so not the right place.

tooreht commented 10 years ago

Thank you for your fast response and the clarifications! So I will have a look at lodash...