Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Pug template is not working with Pug official examples #107

Open
keshon opened this issue Mar 27, 2021 · 2 comments
Open

Pug template is not working with Pug official examples #107

keshon opened this issue Mar 27, 2021 · 2 comments
Labels
☢️ Bug Something isn't working

Comments

@keshon
Copy link

keshon commented Mar 27, 2021

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
@keshon
Copy link
Author

keshon commented Mar 27, 2021

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

@ReneWerner87 ReneWerner87 added the ☢️ Bug Something isn't working label Apr 11, 2021
@laeo
Copy link

laeo commented Mar 2, 2022

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
☢️ Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants