【发布时间】:2012-08-08 09:36:13
【问题描述】:
以如下结构为例:
{% set paths = {
...
'js': {
...
'jquery': {
'version': '1.7.2',
'cdn': 'https://ajax.googleapis.com/ajax/libs/jquery/{{paths.js.jquery.version}}/jquery.min.js',
'fallback': ....
}
}
}
%}
要访问,我通常会使用以下内容:
<script src="{{paths.js.jquery.cdn}}"></script>
问题:
无法识别内插变量,您会得到类似...libs/jquery/%7B%7B%paths.js/jquery.version7D%7D/jquery.min.js... 的信息。
我试过了:
-
'a': 'text{{b}}text', -
'a': {{ ('text' ~ b ~ 'text') }}, -
'a': "{{ ('text' ~ b ~ 'text') }}", -
'a': "{{ (['text', b, 'text'] | join }}", 'a': "{{ (['text', {{b}}, 'text'] | join }}"- 还有更多我忘记了
我知道属性()
关于它的文档不多,但据我所知,它必须是这样的:
attribute(paths, attribute(js, attribute(jquery, cdn)))
对于一个级别来说可以,但不是任意级别的深度。如果我误解了attribute(),请纠正我。
【问题讨论】:
标签: object twig interpolation templating templating-engine