Can verbatim be used on contents of an include?

symfony, twig

Solution

I ran into the same problem, and this page came up in my search results. In the time since this question was answered, the Twig developers added this functionality into the library. I figured I should add some details for future searchers.

The functionality to include raw text (aka for client-side templates using the same syntax as Twig) is accomplished with the `source` function.

Ie: `{{ source('path/to/template.html.twig') }}`

http://twig.sensiolabs.org/doc/functions/source.html

Problem

I'm sharing templates between client and server and would like to output the raw template inside a script tag which is possible with verbatim. http://twig.sensiolabs.org/doc/tags/verbatim.html However it would be nicer if this could be applied as a filter to the include but it doesn't seem possible? I'm new to twig so excuse me if i've missed obvious functionality.

Original source