Package ratpack.groovy.template
Interface TextTemplateScript
-
public interface TextTemplateScript
The API available in template files.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TextTemplateModel
getModel()
The backing model for this template.String
html(Object value)
Escapes the toString() value of the given object, by way ofHtmlEscapers
.String
render(String templateName)
Renders a nested template inline, using the same model as this template.String
render(Map<String,?> model, String templateName)
Renders a nested template inline, with the given model merged with the current template model.String
urlParam(Object value)
Escapes the toString() value of the given object, by way ofUrlEscapers.urlFormParameterEscaper()
.String
urlPathSegment(Object value)
Escapes the toString() value of the given object, by way ofUrlEscapers.urlPathSegmentEscaper()
.
-
-
-
Method Detail
-
getModel
TextTemplateModel getModel()
The backing model for this template.- Returns:
- The backing model for this template
-
render
String render(String templateName) throws Exception
Renders a nested template inline, using the same model as this template.- Parameters:
templateName
- The name of the template to render- Returns:
- An empty string
- Throws:
Exception
- if an error occurs compiling/executing the template- See Also:
render(java.util.Map, String)
-
render
String render(Map<String,?> model, String templateName) throws Exception
Renders a nested template inline, with the given model merged with the current template model.The nested template will be rendered directly to the underlying buffer; it is not returned from this method. This method returns an empty string so that it can be used in situations where the return value would have been included in the output (e.g. a
<?= ?>
block).The template name is resolved into a template using the same renderer that initiated rendering of this template.
- Parameters:
model
- The model to merge with the current template modeltemplateName
- The name of the template to render- Returns:
- The rendered template content
- Throws:
Exception
- if an error occurs compiling/executing the template
-
html
String html(Object value)
Escapes the toString() value of the given object, by way ofHtmlEscapers
.- Parameters:
value
- the value to escape- Returns:
- a minimally escaped version of the given value
-
urlParam
String urlParam(Object value)
Escapes the toString() value of the given object, by way ofUrlEscapers.urlFormParameterEscaper()
.- Parameters:
value
- the value to escape- Returns:
- an escaped version of the given value
-
-