Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A quick recap on twig file extensions (taken from the documentation):</p> <blockquote> <p>Every template name also has two extensions that specify the format and engine for that template.</p> </blockquote> <pre><code>AcmeBlogBundle:Blog:index.html.twig - HTML format, Twig engine AcmeBlogBundle:Blog:index.html.php - HTML format, PHP engine AcmeBlogBundle:Blog:index.css.twig - CSS format, Twig engine </code></pre> <blockquote> <p>By default, any Symfony2 template can be written in either Twig or PHP, and the last part of the extension (e.g. .twig or .php) specifies which of these two engines should be used. The first part of the extension, (e.g. .html, .css, etc) is the final format that the template will generate.</p> </blockquote> <p>Therefore it makes sense to me that including a file as .html would be at the least ambiguous even if it didn't throw an error.</p> <p>So you have 3 choices:</p> <ol> <li><p>If the files are purely javascript then include them as script tags in your page. </p></li> <li><p>If they are mixed HTML and JS then escape the JS with {% raw %} and include the files as foo.html.twig templates. If there are lots of scripts being included like this then most likely your designers could do with a little refactoring and move the bulk of their scripts to external files (see option 1)</p></li> <li><p>If you really insist you could always write a Twig extension to include raw HTML files. (EDIT: See @Haprog's answer below for more details on this option).</p> <p>{{ include_html('foo/bar.html') }}</p></li> <li><p><strong>UPDATE 2015</strong> twig has since added the source function:</p></li> </ol> <p><code>{{ source('AcmeSomeBundle:Default:somefile.html.twig') }}</code></p> <p>Kudos to @Nigel Angel in the comments below for option 4. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload