template
template copied to clipboard
Pug template is not working with Pug official examples
I'm struggled with PUG template using official PUG example like this one:
- var user = {description: 'foo bar baz'}
- var authorised = false
#user
if user.description
h2.green Description
p.description= user.description
else if authorised
h2.blue Description
p.description.
User has no description,
why not add one...
else
h2.red Description
p.description User has no description
I'm getting this error:
template:5: template:9: Error lex: lexClass: expect class name line: 9
Also comparison with == operator:
if .someVar== "someValue"
div someVar has someValue
leads to:
template: index:131: unexpected "=" in operand
I feel a lot of confusion here especially with '.' prefix before variable in Basic example. Maybe this is the issue but what is right example of making simple comparison in fiber Pug template? I tried every combination with no expected results
The pug engine is just translate pug syntax to golang template syntax, so you could use eq directive to accomplish your string comparision.
if eq .someVar "someValue"
div someVar has someValue