pug-php / pug

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

Symbols {} escaped to %7B%7D #120

Closed Riant closed 7 years ago

Riant commented 7 years ago

Hello,

I encountered an issue with the following code:

a(title=$userinfo['user_name'] .'{{hello}}' href=URL::route('ucenter/del_item') .'?id={{id}}') Delete

I expected to get:

<a title="xxx{{hello}}" href="//192.168.xx.xx:4000/ucenter/del-item?id={{id}}">Delete</a>

But I actually get:

<a title="xxx{{hello}}" href="//192.168.xx.xx:4000/ucenter/del-item?id=%7B%7Bid%7D%7D">Delete</a>

I am using Laravel-pug for now, and I do not know if it's a pug-php issue.

Thanks!

kylekatarnls commented 7 years ago

Hi,

To know if an error occurs on pug-php or from your framework extension, you can test your code in http://pug-demo.herokuapp.com/

I tried with:

a(title=$userinfo['user_name'] .'{{hello}}' href=strtolower('ucenter/del_item') .'?id={{id}}') Delete

I just replaced URL::route since it's Laraval facade. And with the data:

array(
  'userinfo' => array(
    'user_name' => 'Bob'
  ),
)

I get the expected result:

<a title="Bob{{hello}}" href="ucenter/del_item?id={{id}}">Delete</a>

Are you up to date with your dependencies? Is this code in a mixin? Have some &attributes()stuff?

So it seems there is a urlencode feature in laravel-pug or laravel, it could be here: https://github.com/BKWLD/laravel-pug/blob/master/src/PugBladeCompiler.php#L47

But I'm not sure.

If you cannot reproduce it with pug-php only, you should open an issue on laravel-pug and I will try to help them to fix it.

Riant commented 7 years ago

Thanks, it looks like Laravel did attributes urlencode.

rulatir commented 1 year ago

What is the current working URL for that pug sandbox?