groovy.text
Class GStringTemplateEngine.GStringTemplate
java.lang.Object
groovy.text.GStringTemplateEngine.GStringTemplate
- All Implemented Interfaces:
- Template
- Enclosing class:
- GStringTemplateEngine
- private static class GStringTemplateEngine.GStringTemplate
- extends java.lang.Object
- implements Template
Constructor Summary |
GStringTemplateEngine.GStringTemplate(java.io.Reader reader)
Turn the template into a writable Closure
When executed the closure evaluates all the code embedded in the
template and then writes a GString containing the fixed and variable items
to the writer passed as a paramater
For example:
'<%= "test" %> of expr and <% test = 1 %>${test} script.'
would compile into:
{ |out| out << "${"test"} of expr and "; test = 1 ; out << "${test} script."}.asWritable() |
Method Summary |
private static void |
appendCharacter(char c,
java.lang.StringBuffer templateExpressions,
boolean writingString)
|
Writable |
make()
|
Writable |
make(java.util.Map map)
|
private static void |
parseExpression(java.io.Reader reader,
boolean writingString,
java.lang.StringBuffer templateExpressions)
Parse a <%= .... |
private static void |
parseSection(java.io.Reader reader,
boolean writingString,
java.lang.StringBuffer templateExpressions)
Parse a <% .... |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
template
final Closure template
GStringTemplateEngine.GStringTemplate
public GStringTemplateEngine.GStringTemplate(java.io.Reader reader)
throws CompilationFailedException,
java.lang.ClassNotFoundException,
java.io.IOException
- Turn the template into a writable Closure
When executed the closure evaluates all the code embedded in the
template and then writes a GString containing the fixed and variable items
to the writer passed as a paramater
For example:
'<%= "test" %> of expr and <% test = 1 %>${test} script.'
would compile into:
{ |out| out << "${"test"} of expr and "; test = 1 ; out << "${test} script."}.asWritable()
- Parameters:
reader
-
- Throws:
CompilationFailedException
java.lang.ClassNotFoundException
java.io.IOException
appendCharacter
private static void appendCharacter(char c,
java.lang.StringBuffer templateExpressions,
boolean writingString)
parseSection
private static void parseSection(java.io.Reader reader,
boolean writingString,
java.lang.StringBuffer templateExpressions)
throws java.io.IOException
- Parse a <% .... %> section
if we are writing a GString close and append ';'
then write the section as a statement
- Parameters:
reader
- writingString
- templateExpressions
-
- Throws:
java.io.IOException
parseExpression
private static void parseExpression(java.io.Reader reader,
boolean writingString,
java.lang.StringBuffer templateExpressions)
throws java.io.IOException
- Parse a <%= .... %> expression
- Parameters:
reader
- writingString
- templateExpressions
-
- Throws:
java.io.IOException
make
public Writable make()
- Specified by:
make
in interface Template
make
public Writable make(java.util.Map map)
- Specified by:
make
in interface Template
Copyright © 2003-2005 The Codehaus. All Rights Reserved.