Can an object tell Twig not to escape output when it is {{ printed }}

Twig
I've got a situation where some variables sent to my Twig templates are plain old variables, so I want them to be html-escaped (as is the default beha...
11 months ago

Twig loop grouping divs

Twig
I want to populate a twig page with information stored in the database. I use a loop to make multiple divs containing different entries of the same ta...
11 months ago

Using twig variable inside load jQuery

Twig
I have a problem with including twig inside load function of jQuery, here is an example: <!-- src/MyBundle/Ressources/views/index.html.twig -->...
11 months ago

How to insert a Controller in Twig with “render” in Silex

Twig
Should it work in Silex with symfony/twig-bridge ? {{ render(controller('MyController')) }} Now I have message like this: Twig_Error_Syntax: Th...
11 months ago

Send associative array from HTML to JS

Twig
I need to send few values through html data attribute to JS. <div class="article" data-article="[{% for data in article %}{{ data }},{% e...
11 months ago

Symfony-Twig: insert fontawesome icon in a form_widget

Twig
To validate a form I am using a standard: {{ form_widget(form.save, {'attr': {'class': 'btn btn-sm btn-danger'}, 'label': 'Submit form'}) }} I want...
11 months ago

How to use php json_encode options in twig file with json_encode twig function

Twig
I am trying to use twig json_encode function but when I do this var packageDetails = {{(packageDetails|json_encode)}}; and packageDetails is a...
11 months ago

php twig get variables passed to render in extension function

Twig
I swear I've googled this and tried to understand the docs, but I'm just not getting it. I'm writing a twig function, what I can't understand is how I...
11 months ago

Setup twitter bootstrap, in slim php, after downloading via composer?

Twig
I've installed twitter bootstrap via composer and don't have any idea how to reference it in a twig view. I suppose there's a namespace for it but I d...
11 months ago

twig: check if all included arrays in an object are empty

Twig
I have a twig variable containing a number of named array objects like this: {{ dump(trashbin) }} Output: array:2 [ "Campaign" => [] "Clien...
11 months ago

Drupal 8 how to pass a value to menu twig template

Twig
I am new to Drupal, I want to pass domain URL to use in menu.html.twig template. How can I do this. Actually I have a menu of 5 domains all pointing t...
11 months ago

Twig check if value in array is true

Twig
I have an array which contains booleans. How do I search the array to see if one or more is true and then display the something once? Here is my co...
11 months ago

Can I put html inside a Symfony form button with Twig?

Twig
I'm trying to put html inside a form button with twig like: {{ form_widget(form.jiraStatus, { 'label': '<i class="fa fa-bug"></i>...
10 months ago

Check if template exists before rendering

Twig
is there a way to check if twig template exists before calling to render? A try catch block seems not to work, at least in dev environment, and plus, ...
10 months ago

Doctrine connection in Twig extension - Symfony

Twig
According to what I've read online, it should be possible to create Doctrine connection inside Twig extensions file. I'd like to create an extension w...
10 months ago

Symfony/Twig: internal ID for form widgets?

Twig
I've to modify the radio_widget and would like to give the <label> and <input> the same ID, which should be unique for each pair. Current...
10 months ago

Twig template - Loop iteration sum items in loop

Twig
{% for product in products %} {% set totalPrice = (product.quantity * product.price)|number_format(2, '.', ',') %} {% endfor %} {{ totalPrice }}...
10 months ago

How to render twig templates into a service. Is it Best practice?

Twig
I have the following Symfony 3 controller: public function register(Request $request) { $username=$request->get('username'); $password=...
10 months ago

Variable as name of row in TWIG : Symfony 2

Twig
I have a problem in my Symfony2 application. In Controller I'm getting an array of facebook users and posting it to my form class, where I create some...
10 months ago

Symfony: How to render a template as a simple txt

Twig
I have to render a template of an action as a simple .txt file. How can I do this? Is there a way other than using the Response object? Using a Resp...
10 months ago