Questions about the Symfony pass value and the asset inside the Twig

Source: Internet
Author: User
Using the Symfony framework, I passed two values from the background to the twig, and then I wanted to assign the value to asset (), what should I do? The code for the controller passing 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 the above method is not, that Cfgimagepath and paginations.getadvsimagepath these two variables together is a picture of the path, I changed how to pass the value or write twig inside the code to achieve it. Just start with symfony, a lot of not very understand, forget you are generous enlighten.

Reply content:

Using the Symfony framework, I passed two values from the background to the twig, and then I wanted to assign the value to asset (), what should I do? The code for the controller passing 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 the above method is not, that Cfgimagepath and paginations.getadvsimagepath these two variables together is a picture of the path, I changed how to pass the value or write twig inside the code to achieve it. Just start with symfony, a lot of not very understand, forget you are generous enlighten.

Short answer: You need to use the " ~ " operator (see twig documentation)

Long answer:

You need to change the picture label to the following:

Explain:

    1. " {{ }} " cannot be nested

    2. Concatenate two or more variables, strings, with the " ~ " operator, equivalent to the PHP " . " operator

    3. assetis twig a function, the passed variable is for the function, instead of the output to the HTML, there should be no quotation marks

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.