在TagLib中,如何检索正文的原始文本代码?

时间:2013-06-11 17:03:38

标签: grails taglib

现在,当我定义一个新的TagLib时,body是某种类型的Closure

class MyTagLib {
   static namespace = "my"

   def tag = { attrs, body ->
           // here I would like to retrieve the actual text of the body not
           // its interpretation
           def text = body() 
   }

   def anothertag = { atts, body ->
       out << body ()
   }
}

给出以下gsp:

<my:tag name="example">
   <h1>This is an example</h1>
   <my:anothertag/>
</my:tag> 

我希望我的:标签检索整个文本而不仅仅是执行h1和my:anothertab的结果

由于

帕斯卡

0 个答案:

没有答案