문제

For pages with lots of text and html tags, I quickly get a parsing error from Twig due to unexpected special characters. Has anybody else ran into this problem?

Unexpected character "!" in ... at line 76

I am trying to fix this problem by pasting the static information in a new page and then including it using include.

My question is, where should I place a static HTML file so it can be included in a Twig file using {% include 'content.html' %}? Currently the included file is in the FooBundle/Resources/views/Default directory.

What is a good practice for overcoming this problem, and if include is the answer, where should the file be located to be included in a twig?

Note:

When I try to link to it using {% include 'content.html' %} I get the following Symfony error:

Unable to find template "content.html" in ... at line 31 (broken link)

도움이 되었습니까?

해결책

I found a solution, drawing from various different posts. I ended up putting the raw html in a new file (which isn't required) and included it as follows:

{% include 'FooBundle:Default:content.html.twig' %}

Then inside my content.html.twig I surrounded my raw HTML code with raw Twig tags:

{% raw %}

// RAW HTML CODE HERE

{% endraw %}

다른 팁

Include like this

{% include 'YourProjectNameFooBundle:Default/content.html.twig' %}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top