freemarker.ext.misc
Class Split

java.lang.Object
  extended by freemarker.ext.misc.Split
All Implemented Interfaces:
TemplateMethodModel2, TemplateModel, java.io.Serializable

public final class Split
extends java.lang.Object
implements TemplateMethodModel2, java.io.Serializable

A method model that implements the Perl 5 split function. This uses the Jakarta ORO library to perform the split.

Usage:
From java:

 TemplateModelRoot root = new SimpleHash();

 root.put( "split", new freemarker.ext.misc.Split() );

 ...
 

From your FM-Classic template:

 The following lists each directory in the path:
 <assign path = "/var/log/apache/">
 <assign output = split( "/\\//", path )>
 <foreach item in output>
 %{item}
 </foreach>

 ...
 

Since:
1.8.2
Version:
$Id: Split.java 1101 2013-04-01 04:17:32Z run2000 $
Author:
Nicholas Cull
See Also:
Serialized Form

Constructor Summary
Split()
          Create a new split method.
 
Method Summary
 TemplateModel exec(java.util.List<TemplateModel> arguments)
          Executes a method call.
 boolean isEmpty()
          Is the object empty?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Split

public Split()
Create a new split method.

Method Detail

isEmpty

public boolean isEmpty()
Is the object empty?

Specified by:
isEmpty in interface TemplateModel
Returns:
false to indicate the method is not empty

exec

public TemplateModel exec(java.util.List<TemplateModel> arguments)
                   throws TemplateModelException
Executes a method call. Arguments are passed as a List of TemplateModel objects.

Specified by:
exec in interface TemplateMethodModel2
Parameters:
arguments - a List of TemplateModel objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.
Throws:
TemplateModelException