I’m trying to consume a html template with a Grails app. I’m given a URL and need to dynamically load the html into my Grails views on run time. Within the HTML code there is a {title} and a {content} tag, where my Grails code will be injected.
In PHP it would be something like include(“url”); Now how do we do this in Grails, or is it possible?
without caching and without a real tempalting solition, you code could look like this:
but Raphael is absolutly right: you should take a look at the groovy template framework if you need a more sophisticated solution (http://groovy.codehaus.org/Groovy+Templates).
With the template framework, you would first prepare your template
and save it to the database as cache. When you have to greate your HTML page, you would fetch the template and let groovy replace the placeholders:
that’s it.