Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Leaf, the else condition isn't properly executed though the if one is

I have a simple Leaf template that I'd like to display Hello World in.

#if(false) {
<title> All hail Apodron.</title>
} #else {
<title> Hello World </title>
}

the page has no title and displays as:

#else {Helloward}

However, if I change this to:

#if(true) {
<title> All hail Apodron.</title>
} #else {
<title> Hello World </title>
}

then the title does display, but the page STILL shows up as:

#else {Helloward}

I also tried various syntaxes, such as:

##else { <title> Hello World </title> } and #else() { <title> Hello World </title> } or even ##else() { <title> Hello World </title> }

This seemed very basic, and I believe I followed the documentation.

like image 756
YannickR Avatar asked Oct 26 '25 06:10

YannickR


1 Answers

It looks like your problem is Leaf is expecting else, but are using #else. So changing your template to this should fix it:

#if(false) {
  <title> All hail Apodron.</title>
} else {
  <title> Hello World </title>
}

Here is the relevant documentation.

like image 93
Caleb Kleveter Avatar answered Oct 29 '25 08:10

Caleb Kleveter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!