Search in sources :

Example 21 with IStandardExpression

use of org.thymeleaf.standard.expression.IStandardExpression in project thymeleaf-tests by thymeleaf.

the class AddLocalVariableToNode method processAttribute.

@Override
protected ProcessorResult processAttribute(final Arguments arguments, final Element element, final String attributeName) {
    final String attributeValue = element.getAttributeValue(attributeName);
    final Configuration configuration = arguments.getConfiguration();
    final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
    final AssignationSequence assignationSequence = AssignationUtils.parseAssignationSequence(configuration, arguments, attributeValue, false);
    for (final Assignation assignation : assignationSequence.getAssignations()) {
        final IStandardExpression varNameExpr = assignation.getLeft();
        final IStandardExpression varValueExpr = assignation.getRight();
        final Object varName = varNameExpr.execute(configuration, arguments);
        final Object varValue = varValueExpr.execute(configuration, arguments);
        element.setNodeLocalVariable((varName == null ? null : varName.toString()), varValue);
    }
    element.removeAttribute(attributeName);
    return ProcessorResult.OK;
}
Also used : IStandardExpression(org.thymeleaf.standard.expression.IStandardExpression) Configuration(org.thymeleaf.Configuration) IStandardExpressionParser(org.thymeleaf.standard.expression.IStandardExpressionParser) AssignationSequence(org.thymeleaf.standard.expression.AssignationSequence) Assignation(org.thymeleaf.standard.expression.Assignation)

Aggregations

IStandardExpression (org.thymeleaf.standard.expression.IStandardExpression)21 IStandardExpressionParser (org.thymeleaf.standard.expression.IStandardExpressionParser)11 TemplateProcessingException (org.thymeleaf.exceptions.TemplateProcessingException)7 Assignation (org.thymeleaf.standard.expression.Assignation)6 AssignationSequence (org.thymeleaf.standard.expression.AssignationSequence)6 FragmentExpression (org.thymeleaf.standard.expression.FragmentExpression)5 Configuration (org.thymeleaf.Configuration)4 HashMap (java.util.HashMap)2 IEngineConfiguration (org.thymeleaf.IEngineConfiguration)2 Fragment (org.thymeleaf.standard.expression.Fragment)2 StandardExpressionExecutionContext (org.thymeleaf.standard.expression.StandardExpressionExecutionContext)2 IOException (java.io.IOException)1 Map (java.util.Map)1 ServletException (javax.servlet.ServletException)1 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)1 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)1 RequestDispatcherOptions (org.apache.sling.api.request.RequestDispatcherOptions)1 Resource (org.apache.sling.api.resource.Resource)1 SyntheticResource (org.apache.sling.api.resource.SyntheticResource)1 IEngineContext (org.thymeleaf.context.IEngineContext)1