-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Local variables aren't working #1497
Comments
Are you compiling for client (this has changed) ? Also, be careful or |
If I remove space. I still don't receive desired behavour #some-id
myLocalVariable= self.getSomeStuff()
if myLocalVariable.isOk()
.positive= myLocalVariable.getResult()
else
.negative= myLocalVariable.getError() Compiles to function template(locals) {
var buf = [];
var jade_mixins = {};
var locals_ = locals || {}, self = locals_.self, myLocalVariable = locals_.myLocalVariable;
buf.push('<div id="some-id"><myLocalVariable>' + jade.escape(null == (jade.interp = self.getSomeStuff()) ? "" : jade.interp) + "</myLocalVariable>");
if (myLocalVariable.isOk()) {
buf.push('<div class="positive">' + jade.escape(null == (jade.interp = myLocalVariable.getResult()) ? "" : jade.interp) + "</div>");
} else {
buf.push('<div class="negative">' + jade.escape(null == (jade.interp = myLocalVariable.getError()) ? "" : jade.interp) + "</div>");
}
buf.push("</div>");
return buf.join("");
} The thing is that with or without space, the result is not it was last year :) Point is, if this was changed, why there is no error or warning at compile time? |
again -- I think the "undefined" error comes from the fact that you're not compiling it with client : http://jade-lang.com/command-line/ |
http://jade-lang.com/demo/ - does this compile with --client ? I also compile with jade.compile() API in web browser. I don't see any option equal to --client here http://jade-lang.com/api/ :( |
it's |
Is following correct ? jade.compile(content, {client: true, compileDebug: true, self: true}) Just to clear it. The error is there because myLocalVariable is not set with return of self.getSomeStuff(). But it was few version ago. |
No, you need to use the |
Nevertheles, both myLocalVariable = self.getSomeStuff() is compiled to buf.push('<div id="some-id"><myLocalVariable>= self.getSomeStuff()</myLocalVariable>'); and gives no compilation error or warning. It compiled to something like myLocalVariable = self.getSomeStuff() few versions ago. Also not a word about droping |
Yeah, EDIT : Just understood you expect it to be an assignment. use |
#some-id
var myLocalVariable = self.getSomeStuff() is compiled to function template(locals) {
var buf = [];
var jade_mixins = {};
buf.push('<div id="some-id"><var>myLocalVariable = self.getSomeStuff()</var></div>');
return buf.join("");
} Still not the result I want |
It's |
So the question is: Why few versions ago
|
Yes, sorry I didn't get to this sooner. The problem is simply that we removed support for first class variable assignment/declaration in v1.0.0 (see "Remove special assignment syntax" in the change log) The fix is simply to use The reasoning for the change was because the old syntax caused a great deal of confusion because people tended to assume it behaved as assignment when in fact it behaved as variable declaration. It was also tricky as it looked too much like |
In case it wasn't clear, any line that begins with |
It will be a lot easier to get up-to-date if there were some migration warnings about syntax that were dropped or so. Or some checker tool that shows pit falls. May be a good idea to add special |
We have a change log, and we were pre v1.0.0. Now that we are post 1.0.0 we follow semver which means you will get a version that I'm not keen to add a |
Btw, why is function-typed options.locals(options.data) getting not working? |
@fritx |
Oic, thanks. But how about supporting it just in jade? 😃 |
Hi, there.
I have not updated to latest for a while. And after recent update I've discovered, that the following is not working any more
But the thing is, that if this syntax is forbidden. Why it does not trigger compile time error. Also it has really nice syntax highlight at online demo.
Here how it's compiled (online demo @ jade-lang.com)
Also it fails at runtime with following error
The text was updated successfully, but these errors were encountered: