org.apache.velocity.runtime.directive
Class Include
java.lang.Object
org.apache.velocity.runtime.directive.Directive
org.apache.velocity.runtime.directive.InputBase
org.apache.velocity.runtime.directive.Include
- All Implemented Interfaces:
- Cloneable, DirectiveConstants
public class Include
- extends InputBase
Pluggable directive that handles the #include() statement in VTL.
This #include() can take multiple arguments of either
StringLiteral or Reference.
Notes:
- For security reasons, the included source material can only come
from somewhere within the template root tree. If you want to include
content from elsewhere on your disk, add extra template roots, or use
a link from somwhere under template root to that content.
- By default, there is no output to the render stream in the event of
a problem. You can override this behavior with two property values :
include.output.errormsg.start
include.output.errormsg.end
If both are defined in velocity.properties, they will be used to
in the render output to bracket the arg string that caused the
problem.
Ex. : if you are working in html then
include.output.errormsg.start=<!-- #include error :
include.output.errormsg.end= -->
might be an excellent way to start...
- As noted above, #include() can take multiple arguments.
Ex : #include('foo.vm' 'bar.vm' $foo)
will include all three if valid to output without any
special separator.
- Version:
- $Id: Include.java 687177 2008-08-19 22:00:32Z nbubna $
- Author:
- Geir Magnusson Jr., Jason van Zyl, Kasper Nielsen
Fields inherited from class org.apache.velocity.runtime.directive.Directive |
rsvc |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Include
public Include()
getName
public String getName()
- Return name of this directive.
- Specified by:
getName
in class Directive
- Returns:
- The name of this directive.
getType
public int getType()
- Return type of this directive.
- Specified by:
getType
in class Directive
- Returns:
- The type of this directive.
init
public void init(RuntimeServices rs,
InternalContextAdapter context,
Node node)
throws TemplateInitException
- simple init - init the tree and get the elementKey from
the AST
- Overrides:
init
in class Directive
- Parameters:
rs
- context
- node
-
- Throws:
TemplateInitException
render
public boolean render(InternalContextAdapter context,
Writer writer,
Node node)
throws IOException,
MethodInvocationException,
ResourceNotFoundException
- iterates through the argument list and renders every
argument that is appropriate. Any non appropriate
arguments are logged, but render() continues.
- Specified by:
render
in class Directive
- Parameters:
context
- writer
- node
-
- Returns:
- True if the directive rendered successfully.
- Throws:
IOException
MethodInvocationException
ResourceNotFoundException
Copyright © 2000-2008 The Apache Software Foundation. All Rights Reserved.