pug-php / pug-symfony

Pug (Jade) template engine for Symfony

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to generate route

wtty opened this issue · comments

commented

I installed pug-symfony in Symfony 4 with no issues but routes are not working for me:

The following route works in twig:

<a href="{{ path('some_route') }}">Home</a>

In pug:

a(href=path('some_route')) Home

It throws this error: Function name must be a string

commented

This syntax worked fro Symfony 3, not tested in real case with Symfony 4. You can try the complete. Here are the short-cuts supposed to be implemented: https://github.com/pug-php/pug-symfony/blob/master/src/Jade/JadeSymfonyEngine.php#L138

So you can try a(href=view.router.path('some_route'))

commented

Those would be great, being able to use translations in pug would be nice too {{ title('page_title'|trans) }}
I tried what you suggested, but it didn't work:

Use of undefined constant view - assumed 'view'

The asset function doesn't seem to work either:

link(rel="stylesheet" href=asset('/build/style.css'))

Error:

Undefined index: assets
commented

Oh, I guess, you set expressionLanguage to php, so you can't use JS-style:

a(href=$view['router']->path('some_route'))

The trans filter just call the symfony translator under the hood, you can pass the translator instance as a local or shared variables to views then just call the method.

commented

I also tried that, but get the following:

Use of undefined constant router - assumed 'router'

Oh ok, I will keep that in mind.