Haml.js:有没有办法插入动态属性值?

时间:2012-05-31 12:51:12

标签: haml

这就是我想要做的事情:

%input.current-page( type="text" value=currentPageNum )

其中 currentPageNum 是动态的。

这就是我调用此模板的方式:

@$el.html( Haml.render( @template, { locals: { currentPageNum: @currentPageNum } } ) )

此问题与haml.js有关,但我没有足够的声誉在此处创建新标记

1 个答案:

答案 0 :(得分:2)

我找到了答案:

%input.current-page{ type: "text", value: "#{currentPageNum}" }

进一步阅读:

https://github.com/creationix/haml-js/blob/master/test/embedded_code.haml

比较

https://github.com/creationix/haml-js/blob/master/test/embedded_code.html