Package 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
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map
templateCache
-
Constructor Summary
Constructors Constructor Description TemplateEngine()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 codeTemplate
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)
-
-
-
Method Detail
-
scriptLoaded
public void scriptLoaded(sleep.runtime.ScriptInstance script)
- Specified by:
scriptLoaded
in interfacesleep.interfaces.Loadable
-
scriptUnloaded
public void scriptUnloaded(sleep.runtime.ScriptInstance script)
- Specified by:
scriptUnloaded
in interfacesleep.interfaces.Loadable
-
evaluate
public sleep.runtime.Scalar evaluate(java.lang.String name, sleep.runtime.ScriptInstance script, java.util.Stack args)
- Specified by:
evaluate
in interfacesleep.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
-
-