com.github.edgarespina.handlebars.Context Maven / Gradle / Ivy
package com.github.edgarespina.handlebars;
import java.util.Map;
/**
* Mustache/Handlabars are contextual template engines. This class represent the
* 'context stack' of a template.
*
* - Objects and hashes should be pushed onto the context stack.
*
- All elements on the context stack should be accessible.
*
- Multiple sections per template should be permitted.
*
- Failed context lookups should be considered falsey.
*
- Dotted names should be valid for Section tags.
*
- Dotted names that cannot be resolved should be considered falsey.
*
- Dotted Names - Context Precedence: Dotted names should be resolved
* against former resolutions.
*
*
* @author edgar.espina
* @since 0.1.0
*/
public interface Context {
/**
* Resolved as '.' or 'this' inside templates.
*
* @return The model or data.
*/
Object model();
/**
* A contextual storage useful for saving values in a thread-safety way. The
* storage is cleaned up once a template has been rendered.
*
* @return A contextual storage. Never null.
*/
Map storage();
/**
* Lookup the given key inside the context stack.
*
* - Objects and hashes should be pushed onto the context stack.
*
- All elements on the context stack should be accessible.
*
- Multiple sections per template should be permitted.
*
- Failed context lookups should be considered falsey.
*
- Dotted names should be valid for Section tags.
*
- Dotted names that cannot be resolved should be considered falsey.
*
- Dotted Names - Context Precedence: Dotted names should be resolved
* against former resolutions.
*
*
* @param key The object key.
* @return The value associated to the given key or null if no
* value is found.
*/
Object get(final Object key);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy