开发者

PHPTAL replace but keep certain attributes?

开发者 https://www.devze.com 2023-03-29 15:17 出处:网络
Is it possible to do a tal:replace=\"whatever\" but maintain certain attributes of the element/tag? For example, if you have the following:

Is it possible to do a tal:replace="whatever" but maintain certain attributes of the element/tag?

For example, if you have the following:

<input type='text' value='test' name='hello' class='specialClass' tal:replace="customInput"/>

Is it possible to have your customInput replace the current input but somehow also have the specialClass class as well?

I 开发者_如何学Pythoncan't tell if PHPTAL allows things like this or if I need to override some PHPTAL method for replacing...


No, you can't. tal:replace completely replaces the element with text, so there is nothing to put these attributes on.

Attributes are preserved with tal:content.

In case of <input>, you'd rather use value="${customValue}" or tal:attributes="value customValue".

PHPTAL doesn't parse any markup at run time, so if you have something that generates <input>'s HTML dynamically for you, then you need to modify that code yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消