开发者

Grails/Groovy taglib handling parsing dynamically inserted tags

开发者 https://www.devze.com 2022-12-21 17:05 出处:网络
Is there a way to have a custom taglib operate on data loaded in a .gsp file such that it picks up any tags embedded in the data stored in the database. For instance, let\'s say I\'m doing:

Is there a way to have a custom taglib operate on data loaded in a .gsp file such that it picks up any tags embedded in the data stored in the database. For instance, let's say I'm doing:

      <g:each in="${activities}">
         <li>开发者_StackOverflow社区;${it.payload}</li>
      </g:each>

And inside the payload, which is coming from the database, is text like

"Person a did event <company:event id="15124124">Event Description</company:event>"

Can you have a taglib that handles company:event tags on the fly?


You could write a custom tag which uses the GroovyPagesTemplateEngine to process the text and write it to the output stream. I think you can get an instance of the TemplateEngine injected into your tag from the applicationContext.

I don't have any example code sorry,

cheers

Lee

0

精彩评论

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

关注公众号