Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Pug 2.7.6 minor correction to avoid warning with block append usage #251

Closed
dadajuice opened this issue Sep 28, 2022 · 4 comments
Closed

Comments

@dadajuice
Copy link

Hello,

I encountered a light issue when using append when used inside an inherited layout. The append behave as expected (it works) but it also throws in a warning. This only happens with at least two levels of "extends".

Example:

layout.pug

doctype html
html
  head
    title Test
  body
    h1 Header
    block content
    br
    br
    p Footer

layout2.pug

extends layout

block content
  p Testing

test.pug

extends layout2

append content
  p Working without warning.

Executing the test.pug rendering gets me the good result, but with the following warning (which does not appears if you have only one level of extends).

Warning: Undefined property: Jade\Nodes\Block::$mode in /var/www/html/vendor/pug-php/pug/src/Jade/Parser.php on line 426

I'm not sure why it happens with multiple inherited files only, but a simple fix would be to verify if the $mode property is set in the method affected by the warning to avoid it. I added the following lines in the method parseBlock() just after the $prev = &$this->blocks[$name]; line :

if (!isset($prev->mode)) {
    return $this->blocks[$name];
}

It fixed the problem in my local version. I was wondering if such a fix would be possible or if you had a better one 😊.

Thank you very much for your time!

@dadajuice
Copy link
Author

dadajuice commented Sep 28, 2022

Please note that there's another issue related to append if you use multiple append with the same context of multiple inherited files. The issue case was for one append block type ... if I would have another file extending with another append somehow the first element of the block doesn't appear (it keeps only the two append value). If you want I can open another issue for this specific case, but since it must be around the same code maybe there's a quick fix you may know of.

Thank you!

@kylekatarnls
Copy link
Member

Hello, can you try if it's all good using composer require pug/pug-php:dev-version-2.next?

@dadajuice
Copy link
Author

Seems all good! 😁 Thank you very much!

@kylekatarnls
Copy link
Member

Tag released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants