The symfony framework is used. I transfer two values from the background to twig, and then want to assign values to asset (). What should I do? The Code passed by the Controller is as follows: {code ...} the twig code is as follows: {code ...} I know that the above method is not feasible, then define ImagePath and paginatio... the symfony framework is used. I transfer two values from the background to twig, and then want to assign values to asset (). What should I do? The code for the Controller to pass the value is as follows:
return $this->render("AcmeMinsuBundle:Default:advsImage.html.twig", array('pagination' => $pagination,'cfgImagePath' => $cfgImagePath) );
The twig code is as follows:
{% for paginations in pagination %}
{% endfor %}
I know that the above method is not feasible. Then, the variables ImagePath and paginations. getAdvsImagePath are combined to form an image path. How can I transfer the value or write the code in twig to achieve this. At the beginning, I started to use symfony, but I don't know much about it.
Reply content:
The symfony framework is used. I transfer two values from the background to twig, and then want to assign values to asset (). What should I do? The code for the Controller to pass the value is as follows:
return $this->render("AcmeMinsuBundle:Default:advsImage.html.twig", array('pagination' => $pagination,'cfgImagePath' => $cfgImagePath) );
The twig code is as follows:
{% for paginations in pagination %}
{% endfor %}
I know that the above method is not feasible. Then, the variables ImagePath and paginations. getAdvsImagePath are combined to form an image path. How can I transfer the value or write the code in twig to achieve this. At the beginning, I started to use symfony, but I don't know much about it.
Short answer: You need to use"~
"Operator (see Twig documentation) Long answer:
You need to change the image label to the following:
Explanation:
"{{ }}
"Cannot be nested
Connect two or more variables and strings, and use"~
"Operator, equivalent to PHP".
"Operator
asset
Yestwig
The input variable is used by the function, rather than HTML. No quotation marks are provided here.