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
Allow multiline JS var definition #796
Comments
you could use: - var config = {
- a: 'something',
- b: 'something-else'
- } |
Tried that but compiling gives me the following:
|
Similarly, this code does not work either:
|
this looks like it is related to #629 |
multiline mixins is arguable but i dont want this sort of thing, config etc should be outside of jade |
if this is valid JS (which I think it is) it should work. I am not interested in adding configuration inside of templates, but if there is something wrong with the way that Jade parses inline JS it should be fixed (no matter what bad organization of code it might allow developers to use). |
I dont have infinite time and it's not something I would personally want, but I'll welcome a pull-request if it's not too large / hacky |
@visionmedia where would I want to look to possibly implement this feature? |
For starters, it would mean some new syntax (e.g. we have - var config = {
- a: 'something',
- b: 'something-else'
- } to work, and I'd say it's pretty much just a bug that it doesn't already. We could equally definitely get: config = {
a: 'something',
b: 'something-else'
} to work by using |
Request for comments. How about that syntax? config = { \
a: 'something', \
b: 'something-else'
} Line ending escaping is bash's practice. |
so was this killed? |
Should work, but doesn't and requires a lot more cleverness to make work: - var config = {
- a: 'something',
- b: 'something-else'
- } I would probably accept a pull request to make work, but don't have time or inclination to write myself: -
var config = {
a: 'something',
b: 'something-else'
} |
so I accomplished what I wanted by passing in the array in grunt-contrib-jade instead of putting it directly in the template. Also allowed me to get rid of grunt-sed |
That's the preferred method of doing this, and the reason why this is low priority for me. |
+1 with the request. This would open an alternative for compiling Jade. It would open Jade to GUIs, like Codekit, solving issue #833. |
+1 |
2 similar comments
+1 |
+1 |
I am going to go ahead and unlock this issue. Please refrain from adding more +1’s, and limit your comments to constructive implementation details. |
+1, it worked for me as Forbes said here #796 (comment), but only with debug disabled. |
@iliakan it is expected that !debug works as debugging "symbols" are attached in between lines. |
@TimothyGu yes, I felt it's the reason :/ |
@iliakan I'm not extremely motivated to do this. We will accept pull requests for the following syntax though: -
var af = {
prop: 1
} |
If we do need this or think it's helpful I'd say a more generic, faster, and safer implementation would be that of a multi-line JS block similar identifier like /* */ or . This sort of also bumps into the factor of functionality balance though, if I have am doing THIS much in jade that I require such a feature, should this be in Jade? |
@acidjazz said:
I'd rather use the syntax proposed by @ForbesLindesay to be more consistent with the currently used
+1, although in many cases it's just a simply look-up table or loop array, so I guess it's fine. |
👍 I would be happy if someone could implement multi-line JS. |
+1 |
1 similar comment
+1 |
Had the same issue - put together a patch to handle block code like:
|
For make object with jade and array is this best solution: https://gist.github.com/jjhoncv/a6efea5eeb7937cb6f90 |
I leave some aid. look this: Is only jade with var text type - var list = []
- list.push({status: "active", text: "option 1"})
- list.push({status: "", text: "option 2"})
- list.push({status: "", text: "option 3"})
each(item, index in list)
li(class="#{item.status}")
a= item.text Is only jade with var type text and var html type. - var list = []
- list.push({status: "active", text: "option 1"})
- list.push({status: "", text: "<strong>option 2</strong>"})
- list.push({status: "", text: "option 3"})
each(item, index in list)
li(class="#{item.status}")
a= !{item.text} Now for other language side back for example PHP: - var list = []
- list.push({status: "<?php echo $status1;?>", text: "option 1"})
- list.push({status: "<?php echo $status2;?>", text: "<strong>option 2</strong>"})
- list.push({status: "<?php echo $status3;?>", text: "option 3"})
each(item, index in list)
li(class!="#{item.status}")
a= !{item.text} |
|
+1 |
Similar to how this works in Jade:
I'd like to be able to do this:
instead of having to write:
This is a short example, however as config grows it would be much prettier if funky spacing was allowed.
The text was updated successfully, but these errors were encountered: