Groovy web console

subscribe to the feed Subscribe
to this
site

better format for

Published 4 months ago by Anonymous
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def values = [ "1", "2", "3", [5,6,7] ]
def engine = new groovy.text.SimpleTemplateEngine()
def text = '''
<% for (item in values) { %>
We are at item <%= item %> of the list.
Normal newlines are available.
    As well as formatting.
<%if(item instanceof List){
    for (inner in item){%>
        Test inner here
    With \\$ syntax:  ${inner} 
And with ${"<%"} syntax: <%=inner%>
<% }}} %>
'''
println engine.createTemplate(text).make([values: values])