org.apache.shindig.gadgets.templates
Class DefaultTemplateProcessor
java.lang.Object
org.apache.shindig.gadgets.templates.DefaultTemplateProcessor
- All Implemented Interfaces:
- TemplateProcessor
public class DefaultTemplateProcessor
- extends Object
- implements TemplateProcessor
Implements a DOM-based OS templates compiler.
Supports:
- ${...} style expressions in content and attributes
- @if attribute
- @repeat attribute
TODO:
- Handle built-in/custom tags
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PROPERTY_INDEX
public static final String PROPERTY_INDEX
- See Also:
- Constant Field Values
PROPERTY_COUNT
public static final String PROPERTY_COUNT
- See Also:
- Constant Field Values
ATTRIBUTE_IF
public static final String ATTRIBUTE_IF
- See Also:
- Constant Field Values
ATTRIBUTE_INDEX
public static final String ATTRIBUTE_INDEX
- See Also:
- Constant Field Values
ATTRIBUTE_REPEAT
public static final String ATTRIBUTE_REPEAT
- See Also:
- Constant Field Values
ATTRIBUTE_VAR
public static final String ATTRIBUTE_VAR
- See Also:
- Constant Field Values
ATTRIBUTE_CUR
public static final String ATTRIBUTE_CUR
- See Also:
- Constant Field Values
DefaultTemplateProcessor
@Inject
public DefaultTemplateProcessor(Expressions expressions)
processTemplate
public DocumentFragment processTemplate(Element template,
TemplateContext templateContext,
javax.el.ELResolver globals,
TagRegistry registry)
- Process an entire template.
- Specified by:
processTemplate in interface TemplateProcessor
- Parameters:
template - the DOM template, typically a script elementtemplateContext - a template context providing top-level
variablesglobals - ELResolver providing global variables other
than those in the templateContext
- Returns:
- a document fragment with the resolved content
processChildNodes
public void processChildNodes(Node result,
Node source)
- Process the children of an element or document.
- Specified by:
processChildNodes in interface TemplateProcessor
- Parameters:
result - the node to which results should be appendedsource - the node whose children should be processed
getTemplateContext
public TemplateContext getTemplateContext()
- Specified by:
getTemplateContext in interface TemplateProcessor
- Returns:
- the current template context.
processRepeat
public void processRepeat(Node result,
Element element,
Iterable<?> dataList,
Runnable onEachLoop)
- Specified by:
processRepeat in interface TemplateProcessor
- Parameters:
result - element - dataList -
evaluate
public <T> T evaluate(String expression,
Class<T> type,
T defaultValue)
- Evaluates an expression within the scope of this processor's context.
- Specified by:
evaluate in interface TemplateProcessor
- Parameters:
expression - The String expressiontype - Expected result typedefaultValue - Default value to return in case of error
Copyright © 2007-2012. All Rights Reserved.