Closed hason closed 8 years ago
You don't need to write the -
in front of the for(). It's easier than HAML.
A correct for-loop in Tale Jade would look like this:
ul
for $i = 0; $i < 5; $i++
li
Tale Jade supports native for-loops (Notice: the official Jade-implementation doesn't)
Take a look at the result: http://sandbox.jade.talesoft.io/id-56e050a676d8e.html
Yes, but this is a bug. What about an another php or twig expression?
- for article in articles if article.published is true
li= article.title
It's not a bug.
This is Jade, not HAML or Twig.
Take a look at this example: http://sandbox.jade.talesoft.io/id-56e0532c104f6.html
Even taking your first example, it compiles correctly (normally) http://sandbox.jade.talesoft.io/id-56e053a6375fc.html
Also, -
initiates a code
-token, not an expression
token, so the error is probably not generated at this point.
Can you post your whole Jade-file?
Notice that you don't need -
in most cases when working with Jade.
It's meant as a backup when you don't find a Jade-construct that fits.
Tale Jade can handle do
, while
, if
, unless
, for
, each
, else\s*if
, else
, case
and when
without any prefixes. They are native control statements for the language.
The error you're getting is produced when you do something like this
h1= $someVar
p Whatever
since the =
(Which is an expression
in Jade-terminology) doesn't allow child-elements of any kind.
To do that, you can always do
h1
= $someVar
p Whatever
Sorry. I can't reproduce bug, that I reported.
This is valid jade syntax
but tale-jade throws exception