为什么在 a fill-slot
ordefine-macro
元素之外定义的变量在该元素内不可见?
<body tal:define="a string:a">
<metal:content-core fill-slot="content-core">
<metal:content-core define-macro="content-core"
tal:define="b string:b">
<div tal:content="a" />
<div tal:content="b" />
<div tal:content="c" />
</metal:content-core>
</metal:content-core>
</body>
a
无法评估带有变量的 tales-expression 。当然b
是可见的。
另一方面,如果变量c
在如下的封闭元素中定义,define-slot
那么它是可见的。
<div tal:define="c string:c">
<metal:text define-slot="content-core"></metal:text>
</div>
看起来只有在插入插槽后才会评估变量。