creationix / haml-js

Haml ported to server-side Javascript. This is a traditional server-side templating language. Tested with node-js
MIT License
902 stars 110 forks source link

TypeError: undefined is not a function #83

Closed stevenbarragan closed 8 years ago

stevenbarragan commented 10 years ago

Does somebody has any idea about what could be causing this error?

TypeError: undefined is not a function
    at Function.eval (eval at <anonymous> (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp-haml/node_modules/haml/lib/haml.js:595:29), <anonymous>:27:17)
    at Function.<anonymous> (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp-haml/node_modules/haml/lib/haml.js:595:11)
    at execute (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp-haml/node_modules/haml/lib/haml.js:602:8)
    at Function.render (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp-haml/node_modules/haml/lib/haml.js:587:12)
    at hamlStream (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp-haml/index.js:15:21)
    at wrappedMapper (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp-haml/node_modules/map-stream/index.js:84:19)
    at Stream.stream.write (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp-haml/node_modules/map-stream/index.js:96:21)
    at write (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:605:24)
    at flow (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:614:7)
    at Transform.pipeOnReadable (/Users/steven/workspace/gopro/ci-template-editor/editor-screen/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:646:5)
masonicboom commented 9 years ago

try double quotes around your attributes instead of single quotes; that fixed it for me

ypresto commented 9 years ago

I really want to use single quote because haml-lint gem, which uses rubocop syntax checker, warns about it.

RuboCop: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Juanmcuello commented 9 years ago

Same problem here using single quotes. Using double quotes fixes the issue, but that's not an option for me.

soyuka commented 9 years ago

Same issue here,

after investigation (I'm using gulp-haml), when render is called, escaperName is undefined.

A quick fix is to add escaperName = "html_escape"; in the render function or to the variable declaration.

ypresto commented 9 years ago

@soyuka

Ahh, I understand. This library seems to support only JSON in attributes.

https://github.com/creationix/haml-js/blob/master/lib/haml.js#L27

I think automatically replacing ' to " (of course "s inside of it too) if possible will be better for performance. Then skip parse_interpol.

ypresto commented 9 years ago

Just adding single quote test doesn't cause the exception (still not optimized js is generated). It might be issue on gulp side.

ypresto commented 9 years ago

This project seems to be discontinued, isn't it? @aaronblohowiak