pug-php / pug-symfony

Pug (Jade) template engine for Symfony
MIT License
44 stars 3 forks source link

Using conditionals triggers undefined offset #33

Closed coneforapine closed 5 years ago

coneforapine commented 5 years ago
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...

kylekatarnls commented 5 years ago

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
coneforapine commented 5 years ago
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"

kylekatarnls commented 5 years ago

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?

coneforapine commented 5 years ago

Yup, I fixed the statement.

kylekatarnls commented 5 years ago

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

coneforapine commented 5 years ago

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

kylekatarnls commented 5 years ago

Perfect! :)