ee.mare.indrek.jtlt.macros
Class IncludeMacro

Object
  extended byee.mare.indrek.jtlt.macros.MacroAdapter
      extended byee.mare.indrek.jtlt.macros.IncludeMacro
All Implemented Interfaces:
TemplateMacro
Direct Known Subclasses:
IncludePlainMacro

public class IncludeMacro
extends MacroAdapter

A macro (INCLUDE) for including files into a template. You should be careful with using this macro as splitting a template into multiple files can create a nightmare of manageability. Still sometimes it can be put into good use. The included file is also parsed for all macros and also sub-blocks.


Constructor Summary
IncludeMacro(String search_path)
          A search path where from to search for files, different paths separated by either colon or semicolon.
IncludeMacro(String search_path, String name)
           
 
Method Summary
 boolean isParsetime()
          Returns whether a macro is parsetime or not.
 boolean isRecursive()
          Whether to recursively parse the output of this the macro.
 String process(TemplateParams ctx, String name, String args)
          This method is called with given block context whenever a macro with registered name is found inside the tempalate.
 
Methods inherited from class ee.mare.indrek.jtlt.macros.MacroAdapter
getName
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IncludeMacro

public IncludeMacro(String search_path)
A search path where from to search for files, different paths separated by either colon or semicolon.


IncludeMacro

public IncludeMacro(String search_path,
                    String name)
Method Detail

isParsetime

public boolean isParsetime()
Description copied from interface: TemplateMacro
Returns whether a macro is parsetime or not. Being parsetime means here that the macro does not depend on template instance specified parameters and can be resolved at parsing time. But resolving macros only at parsetime is faster than doing it on every created template. Not all instances of macro usage may be parsed at parsetime tho. For example when the result of recursive macro contains it.

Specified by:
isParsetime in interface TemplateMacro
Overrides:
isParsetime in class MacroAdapter

isRecursive

public boolean isRecursive()
Description copied from interface: TemplateMacro
Whether to recursively parse the output of this the macro. If the macro is used at parsetime the result can contain additional sub blocks.

Specified by:
isRecursive in interface TemplateMacro
Overrides:
isRecursive in class MacroAdapter

process

public String process(TemplateParams ctx,
                      String name,
                      String args)
Description copied from interface: TemplateMacro
This method is called with given block context whenever a macro with registered name is found inside the tempalate. The macros are resolved immediately only if they are parsetime, otherwise on every Template.toString the data structures are parsed and macros expanded. If macro is parsetime the ctx is taken from the generator. You can add parameters into the template using the Template.addParam, for parsetime macros you'd have to extend the TemplateGenerator.

Specified by:
process in interface TemplateMacro
Overrides:
process in class MacroAdapter