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
Escaping and Multiline when using #[ ] #1723
Comments
1 is a bug. It's quite difficult to fix properly as it probably requires running the entire lexer just to figure out where the interpolation ends (at the moment we run the js lexer which is way simpler to use but incorrectly identifies your 2 is intentional. Interpolate tags were not intended to support multi-line text as it's really not clear exactly what that would mean in terms of indentation. |
My suspicions were correct :) So for these particular cases do you recommend just using regular html tags?
|
For 1, that's the best bet for now, but we should eventually get round to fixing the bug. For 2, just do p
strong.
This strong text is really really long. This strong
text is really really long. This strong text is really really
long. |
@ForbesLindesay shouldn't |
That is approximately what it should do, but it's not quite that simple. Because of the way tokens like indentation etc. work, it needs to merge the abstract syntax trees, rather than the stream of tokens, There's also the question mark over how we figure out what it means to be an un-matched p not #[img(src='exclamation.png')] even in text p in #[strong the middle] of some text and p interpolation ends with #[code= ']'] We currently support all of those examples. |
Right, merging the AST is probably the safest bet... :) I'm not sure why those are not trivial to the lexer, though. the |
There's a long list of contexts where |
It's been a very long time since I last looked into jade source (and I still voice my opinion all the tome... Sorry hehe) but I don't how it's a problem in a state machine. If the state is "normal" parsing (not in an attribute list or string or ...) you check the nesting level and if <0, you throw something(from the subparser). The main parsers then "catches" it and integrates the AST into the mainline parsing. You may need some special code to handle actual syntax errors, but outside of that is seems somewhat straightforward to me (might be because I've worked like that everytime) |
This will be fixed in v2.0.0 (the new jade-lexer/jade-parser modules already have this problem fixed). In the mean time: p.
#[strong John#{"'"}s strong text] is really strong. Works, although it's a big ugly. |
thanks for the workaround :) looking forward for 2.0.0 |
Yes, I second that. Thank you Forbes! |
Just out of curiosity, will 2.0 also allow multi-line commenting that does not actually end up in the rendered content? Assuming no, would something like the following be possible to include in 2.0:
This follows the current method of commenting by starting with |
You can use multi-line comments like this: //-
This is comment,
and multi-line |
I'm running into the same error with a
Escaping with Modifying it to the folowing does work:
I guess tl;dr is a |
A work around is this: #[code= 'git clone https://github.com/jadejs/jade.git'] |
Use of p This link to #[a(href="http://www.google.co.uk") http://www.google.co.uk] will fail
p But this #[a(href="http://www.google.co.uk") http:www.google.co.uk] will work Continuations are predictably (but only in hindsight for me) fine: p I believe
a(href="http://www.google.co.uk")
| http://www.google.co.uk
| will also work If you need to do that sort of thing a lot, a mixin linkit(url)
a(href="#{url}") #{url}
//
// ... intervening code ...
//
p This also works #[+linkit('http://www.bing.com')] so hurrah for Jade The mixin also has the advantage of cutting down the noise of duplication in the source where you want to embed deep links etc. |
This should be fixed in the master branch, which you can try via:
|
A passing comment that a) the fix notwithstanding, I was surprised the inline mixin works and it feels like it should make other useful behaviour possible and b) in the space of a few weeks I've flipped from "why would I want to get to grips with another templating langage to "why can't I use this everywhere". Really neat design tradeoffs. |
Incidentally, you could write your mixin a bit more neatly as: mixin linkit(url)
a(href=url)= url
|
The use of Jade: p The #[strong chief's] golden warthog is still a mystery. HTML Output: <p>The chief's golden warthog is still a mystery.</p> |
Work around Jade bug pugjs/pug#1723 Some grammar fixes
I've run into a couple of issues when using the #[ ] syntax and I'm starting to think they may be bugs so I'm posting them here to confirm :)
Here's the two issues I'm experiencing:
Using an apostrophe
Error message:
The end of the string was reached with no closing bracket found.]
Using multiple lines
Error message:
The end of the string was reached with no closing bracket found.]
I've tried solving both problems by adding
\
but no luck.The text was updated successfully, but these errors were encountered: