I want to finish a if else
conditional block in Jade, so after if/else nested code can be added.
- var name = 'you';
- if(name != '')
p Hello #{name}
- else
p Hello world
| !!!
With an empty name var I want to get
<p>Hello you!!!</p>
But I get
<p>Hello world</p>
!!!
With name = you
I want to get
<p>Hello world!!!</p>
What I have to change to put more text/tags inside p elements? I mean nested to if/else block and common for both cases. The point is not to repeat in code !!!
A finally block like with try/catch would be good, but it doesn't exist.
Curly braces work inside the inline code
- var name = 'you';
- if(name != '') {
p Hello #{name}
- } else {
p Hello world
- }
| !!!
how you do to put a tag inside both p? eg strong !!!. With your solution, exclamations are brothers of p elements, no of children, no matters if I tabulate strong tag
Simply move the p
tag outside of the if-else block and use |
there instead.
div
- var name = 'you';
p
- if(name != '') {
| Hello #{name}
- } else {
| Hello world
- }
strong !!!