deedubs / require-jade

Add jade to requireJS
MIT License
55 stars 17 forks source link

JS error in produced optimized code #14

Closed isadovskiy closed 11 years ago

isadovskiy commented 11 years ago

Hello.

I have the following jade template:

textarea.note | #{note}

Optimizer produces the following code:

define('jade!app/view/entries-item', ['jade'], function(jade) { return function anonymous(locals, attrs, escape, rethrow, merge) { attrs = attrs || jade.attrs; escape = escape || jade.escape; rethrow = rethrow || jade.rethrow; merge = merge || jade.merge; var buf = []; with (locals || {}) { var interp; buf.push(''); } return buf.join(""); } });

It causes error in browser: "Uncaught TypeError: undefined is not a function" for "escape()" function. It appears not defined. Could you fix?

Thanks, Igor

isadovskiy commented 11 years ago

Looks like "escape" is not propagated via "jade.escape" (escape = escape || jade.escape;)

isadovskiy commented 11 years ago

Some additional information. Everything works fine in optimized JS when using "excludeJade: true" build option. However if excludeJade = false, it causes runtime errors. This is because some important API is missed in this case. As I see, you need to make some additional methods exposed via jade plugin API. I made such adjustment on my end and tested. Works fine both for included and excluded Jade API. I will send updated file to you so you could review and merge the changes into git.

isadovskiy commented 11 years ago

Here are the patched sources:

https://docs.google.com/file/d/0B4Ec_AMB8FX2NUxxU1FfU1hzbkU/edit?usp=sharing

vincentmac commented 11 years ago

Could you please create a PR so I can see what has changed?

isadovskiy commented 11 years ago

Just did. Please review.

On Fri, Mar 15, 2013 at 2:44 AM, Vincent Mac notifications@github.comwrote:

Could you please create a PR so I can see what has changed?

— Reply to this email directly or view it on GitHubhttps://github.com/rocketlabsdev/require-jade/issues/14#issuecomment-14938200 .

vincentmac commented 11 years ago

Please see this comment in the PR #15.

EvanCarroll commented 9 years ago

I'm confused.. I'm also getting this error.