Patternlab / Twig Variable Interpolation doesn't work with string from json

*爱你&永不变心* 提交于 2019-11-28 13:11:55

To solve this issue you would first need to enable the extension Twig_Extension_StringLoader. This give you access to the function template_from_string, which give you the ability to "create" templates inside twig and (re)enable the string interpolation you need.

register extension

$twig->addExtension(new Twig_Extension_StringLoader());

use template_from_string to achieve desired effect

{% set legalLink = 'Datenschutzbedingungen' %}
{{ include(template_from_string('{{ "'~contact.legal~'" }}')) }}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!