pug-php / pug-symfony

Pug (Jade) template engine for Symfony

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using conditionals triggers undefined offset

coneforapine opened this issue · comments

extends /admin/components/AdminBase.pug

block content
    .d-flex.align-items-start
        a(href="/link").card.dashboard-card
            span(data-feather="phone").card-image-top.card-icon
            .card-body
                h4.card-title Lorem ipsum
                if pc === '0'
                p.card-text lorem ipsum
                else
                p.card-text #{pActive} ...

I don't think I screw up something in this point...

commented

Hi, by running composer update you should now get a more helpful error message.

Then I can see yet seems indent is wrong:

                if pc === '0'
                p.card-text lorem ipsum
                else
                p.card-text #{pActive} ...

if-else should be indented:

                if pc === '0'
                    p.card-text lorem ipsum
                else
                    p.card-text #{pActive} ...

All the point of Pug is having your code structured by indentation and indentation is a statement itself:

if pc === '0'
    p I'm visible if pc === '0'
p I'm always visible
ParseError in /mnt/c/Users/conef/Desktop/jobs/yuzbek/templates/admin/pages/dashboard.pug:
syntax error, unexpected 'else' (T_ELSE), expecting end of file on line 226, offset 28

This time it gave me right error message, with long list of elements parsed line by line...

I guess this is a fix of "broken error messages"

commented

This time, you get the right error, you have an else statement after a wrong indent or a truncated expression. Did you fix the indent as explained in my comment above?

Yup, I fixed the statement.

commented

So if you have an other error, please show me the code chunk near from the line 226 of dashboard.pug

I don't got any other errors, thanks for help

commented

Perfect! :)