Gustavo Straube
Gustavo Straube

Reputation: 3861

Using Laravel pagination with Twig templates

I'm using TwigBridge package (barryvdh/laravel-twigbridge) with Laravel. Everything was working fine but when I tried to use a Twig template to render pagination links raw HTML was outputted. I wrote the links call as following:

{{ users.links('includes.paginate') }}

And I have a template file at app/views/includes/paginate.twig.

There is some configuration that I have to change or add?

Upvotes: 0

Views: 1689

Answers (1)

Damien Pirsy
Damien Pirsy

Reputation: 25435

I'm not familiar with that package (I use rcrowe's one), but looking at its config file I see:

 'options' => array(

    'autoescape' => 'html',

 )

* autoescape: Whether to enable auto-escaping (default to html):
| * false: disable auto-escaping
| * true: equivalent to html
| * html, js: set the autoescaping to one of the supported strategies
| * PHP callback: a PHP callback that returns an escaping strategy based on the template "filename"

A bad solution would be to turn off autoescaping, but that would be global and it might affect your app in ways you won't like. Did you try using the raw Twig filter?

{{ users.links('includes.paginate')|raw }}

Upvotes: 2

Related Questions