我制作了两个自定义tagLib,即tabContainer和tab。
def tabContainer = { attrs, body ->
println("body: "+body())
out << '<div class="tab-content">' << body() << '</div>'
}
和
def tab = { attrs, body ->
out << '<div class="tab-pane '+${attrs.active == "true" ? "active" : ""}+'" id="'+attrs.id+'">' << body() << '</div>'
}
现在我想在tabContainer中插入选项卡,就像用户在GSP页面中指定的次数一样 -
<myUI:tabContainer>
<myUI:tab id="hello1">Hello1 contents</myUI:tab>
<myUI:tab id="hello2" active="true">Hello2 contents</myUI:tab>
</myUI:tabContainer>
现在,如果我这样做,则出现以下错误 -
Error processing GroovyPageView: Error executing tag <myUI:tabContainer>: Error executing tag <myUI:tab>: No signature of method: myui.myUITagLib.$() is applicable for argument types: (myui.myUITagLib$_closure14_closure15) values: [myui.myUITagLib$_closure14_closure15@2090a569]
需要:用户在GSP页面上传递的tab
内可以传递任意数量的tabcontainer
。
答案 0 :(得分:2)
像这样更改标签标签。它适合我。
out << '<div class="tab-pane ' + (attrs.active == "true" ? 'active' : '') + '" id="' + attrs.id + '">' << body() << '</div>'