summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9df75bd)
juplo.variables now also accepts an expression as argument.
If the parameter can not be parsed as an expression, it is handeld as before
(i.e. parsed as JSON, if possible, tried to be reolved, if not). If the
expression evaluates to an empty string, the parameter is ignored.
import org.thymeleaf.context.VariablesMap;
import org.thymeleaf.dom.Element;
import org.thymeleaf.dom.Node;
import org.thymeleaf.context.VariablesMap;
import org.thymeleaf.dom.Element;
import org.thymeleaf.dom.Node;
+import org.thymeleaf.exceptions.TemplateProcessingException;
import org.thymeleaf.processor.ProcessorResult;
import org.thymeleaf.processor.attr.AbstractAttrProcessor;
import org.thymeleaf.resourceresolver.IResourceResolver;
import org.thymeleaf.processor.ProcessorResult;
import org.thymeleaf.processor.attr.AbstractAttrProcessor;
import org.thymeleaf.resourceresolver.IResourceResolver;
+import org.thymeleaf.standard.expression.IStandardExpression;
+import org.thymeleaf.standard.expression.IStandardExpressionParser;
+import org.thymeleaf.standard.expression.StandardExpressions;
import org.thymeleaf.templateresolver.ITemplateResolver;
import org.thymeleaf.templateresolver.TemplateResolution;
import org.thymeleaf.templateresolver.ITemplateResolver;
import org.thymeleaf.templateresolver.TemplateResolution;
)
{
Configuration config = arguments.getConfiguration();
)
{
Configuration config = arguments.getConfiguration();
+
+ Configuration configuration = arguments.getConfiguration();
+
String parameter = element.getAttributeValue(name);
String parameter = element.getAttributeValue(name);
+ try
+ {
+ IStandardExpressionParser parser =
+ StandardExpressions.getExpressionParser(configuration);
+ IStandardExpression expression =
+ parser.parseExpression(configuration, arguments, parameter);
+ parameter = (String)expression.execute(configuration, arguments);
+ }
+ catch (TemplateProcessingException e) { }
+
+ if (parameter != null && !parameter.trim().isEmpty())
+ {
+ LOG.info("ignoring empty parameter");
+ return ProcessorResult.OK;
+ }
Iterator<Entry<String, Object>> it = null;
Iterator<Entry<String, Object>> it = null;