template
Class TemplateEngine
java.lang.Object
template.TemplateEngine
- All Implemented Interfaces:
- java.io.Serializable, sleep.interfaces.Function, sleep.interfaces.Loadable
public class TemplateEngine
- extends java.lang.Object
- implements sleep.interfaces.Loadable, sleep.interfaces.Function
This class is an implementation of the Sleep template engine. The template engine constructs
an executable template that consists of strings to print and code to evaluate.
Valid templates include:
<% expression >%>
<?sleep statement(s) ?>
- See Also:
- Serialized Form
Method Summary |
sleep.runtime.Scalar |
evaluate(java.lang.String name,
sleep.runtime.ScriptInstance script,
java.util.Stack args)
|
static void |
main(java.lang.String[] args)
|
protected sleep.engine.Block |
parseCode(java.lang.String name,
int lineNo,
sleep.parser.ImportManager imports,
java.lang.String code)
parses the template code |
Template |
parseTemplate(java.io.File name,
java.lang.String code)
parses a Sleep template file. |
void |
scriptLoaded(sleep.runtime.ScriptInstance script)
|
void |
scriptUnloaded(sleep.runtime.ScriptInstance script)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
templateCache
protected java.util.Map templateCache
TemplateEngine
public TemplateEngine()
scriptLoaded
public void scriptLoaded(sleep.runtime.ScriptInstance script)
- Specified by:
scriptLoaded
in interface sleep.interfaces.Loadable
scriptUnloaded
public void scriptUnloaded(sleep.runtime.ScriptInstance script)
- Specified by:
scriptUnloaded
in interface sleep.interfaces.Loadable
evaluate
public sleep.runtime.Scalar evaluate(java.lang.String name,
sleep.runtime.ScriptInstance script,
java.util.Stack args)
- Specified by:
evaluate
in interface sleep.interfaces.Function
parseCode
protected sleep.engine.Block parseCode(java.lang.String name,
int lineNo,
sleep.parser.ImportManager imports,
java.lang.String code)
throws sleep.error.YourCodeSucksException
- parses the template code
- Throws:
sleep.error.YourCodeSucksException
parseTemplate
public Template parseTemplate(java.io.File name,
java.lang.String code)
throws sleep.error.YourCodeSucksException
- parses a Sleep template file. Lots of fun for the whole family
- Throws:
sleep.error.YourCodeSucksException
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- Throws:
java.lang.Exception