pug-php / pug

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

Slashes in locals are escaped by json_encode #147

Closed hustlahusky closed 7 years ago

hustlahusky commented 7 years ago

I'm using pug-php with nodejs pug-cli and found that slashes in locals had escaped by json_encode. It breaks all urls stored in locals.

For example, I have store favicon path in locals array:

$LOCALS['site'] = [
    'colorScheme' => 'none',
    'favicon' => '/favicon.png'
];

And then i'm use it in my pug template:

link(rel="shortcut icon", href=site.favicon, type="image/png")

I'm getting broken favicon path on rendered page:

<link rel="shortcut icon" href="\/favicon.png" type="image/png">

Is there way to pass some options to json_encode, like JSON_UNESCAPED_SLASHES etc.?

kylekatarnls commented 7 years ago

It probably should be the default. I create a unit test to reproduce the case.

kylekatarnls commented 7 years ago

Confirmed, soon fixed

kylekatarnls commented 7 years ago

Thanks for the help, please upgrade to 2.6.4 to get fixed escape.