代码之家  ›  专栏  ›  技术社区  ›  James Lin

phptal:如何重复添加属性?

  •  1
  • James Lin  · 技术社区  · 15 年前

    attrs['href'] = 'www.google.com';
    attrs['id'] = 'the_link';
    ...
    

    <a href="www.google.com" id="the_link">abc</a>
    
    2 回复  |  直到 11 年前
        1
  •  0
  •   Kornel    15 年前

    抱歉,好未来没有这个概念。您需要固定属性:

    tal:attributes="href attrs/href | nothing; id attrs/id | nothing"
    

    或者自己生成标签:

     ${structure php:generate_tag(attrs)}
    
        2
  •  0
  •   nickhar    12 年前

    上面的答案是对的——你不能“循环属性”

    我知道这是一个旧的线程-但你不能用 tal:attributes --似乎它完全是为了这个自动。(见 http://phptal.org/manual/en/#tal-attributes )

    <a tal:attributes="attrs">abc</a>
    
    推荐文章