pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
391 stars 42 forks source link

Undefined variable when using mixin with concatenation #229

Closed sandrodz closed 5 years ago

sandrodz commented 5 years ago

Problem is caused by + "/images/" part.

Screen Shot 2019-11-04 at 20 33 10 Screen Shot 2019-11-04 at 20 33 16
kylekatarnls commented 5 years ago

Hi,

Problem is caused by + "/images/" part.

I don't think so. According to the message, the local assets_url has not been provided. You should pass it to locals array (render parameter) or as a shared variable.

$pug = new Pug(...);

$pug->displayFile('template.pug', [
  'assets_url' => '/directory',
]);

Thanks,

sandrodz commented 5 years ago

Well. I'm pretty sure I'm passing assets_url, because removing + "/images/" it works.

kylekatarnls commented 5 years ago

assets_url will just return an empty string if not set with default settings. I can't reproduce this. Please provide a minimum chunk of code (including templates, the PHP code and locals values to be rendered) to copy-paste and reproduce your bug.

Ideally, if you can reproduce it on https://pug-demo.herokuapp.com/ you can just provide the template, settings and locals used.