Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2014 Attila Szegedi, Daniel Dekany, Jonathan Revusky
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package freemarker.template;
"directive" template language data type: used as user-defined directives (much like macros) in templates. They can do arbitrary actions, write arbitrary text to the template output, and trigger rendering of their nested content for any number of times.

They are used in templates like <@myDirective foo=1 bar="wombat">...</@myDirective> (or as <@myDirective foo=1 bar="wombat" /> - the nested content is optional).

public interface TemplateDirectiveModel extends TemplateModel
Executes this user-defined directive; called by FreeMarker when the user-defined directive is called in the template.

env the current processing environment. Note that you can access the output Writer by freemarker.core.Environment.getOut().
params the parameters (if any) passed to the directive as a map of key/value pairs where the keys are java.lang.String-s and the values are TemplateModel instances. This is never null. If you need to convert the template models to POJOs, you can use the utility methods in the freemarker.template.utility.DeepUnwrap class.
loopVars an array that corresponds to the "loop variables", in the order as they appear in the directive call. ("Loop variables" are out-parameters that are available to the nested body of the directive; see in the Manual.) You set the loop variables by writing this array. The length of the array gives the number of loop-variables that the caller has specified. Never null, but can be a zero-length array.
body an object that can be used to render the nested content (body) of the directive call. If the directive call has no nested content (i.e., it's like <@myDirective /> or <@myDirective></@myDirective>), then this will be null.
TemplateException If any problem occurs that's not an during writing the template output. When writing the template output fails.
   public void execute(Environment envMap paramsTemplateModel[] loopVars
            TemplateDirectiveBody bodythrows TemplateExceptionIOException;
New to GrepCode? Check out our FAQ X