Search in sources :

Example 11 with IStandardExpressionParser

use of org.thymeleaf.standard.expression.IStandardExpressionParser 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)

Example 12 with IStandardExpressionParser

use of org.thymeleaf.standard.expression.IStandardExpressionParser 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

IStandardExpressionParser (org.thymeleaf.standard.expression.IStandardExpressionParser)12 IStandardExpression (org.thymeleaf.standard.expression.IStandardExpression)11 TemplateProcessingException (org.thymeleaf.exceptions.TemplateProcessingException)3 FragmentExpression (org.thymeleaf.standard.expression.FragmentExpression)3 Configuration (org.thymeleaf.Configuration)2 IEngineConfiguration (org.thymeleaf.IEngineConfiguration)2 Assignation (org.thymeleaf.standard.expression.Assignation)2 AssignationSequence (org.thymeleaf.standard.expression.AssignationSequence)2 Fragment (org.thymeleaf.standard.expression.Fragment)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 AttributeName (org.thymeleaf.engine.AttributeName)1 TemplateModel (org.thymeleaf.engine.TemplateModel)1 IPostProcessor (org.thymeleaf.postprocessor.IPostProcessor)1