markup - Groovy markupbuilder tags -


Is there a way to modify the code from a previous answer

  import groovy Xml .markupBuilder def author = new stringwriter () def builder = new markup builder (author) waits DF = ['one', 'two', 'three'] builder. {Ul {awaiting.each {li (it.toString ())}}} Println writer.toString ()  

So that if you add it instead of a tag - such as

can be 'ol' or 'ul' for

  builder.html {tag example {awaiting.each {}}} example  < / Div> 

You can rely on GSTing and the fact that you can call the function by your string value You can. groovy .xml.MarkupBuilder def author = new stringwriter () def Builder = new markupbilder (author) waits waits = ['one', 'two', 'three' ] Df tag = 'ol' builder html {"$ tag" awaiting.each {li (it.toString ())}}} println writer.toString ()


Comments