Search in sources :

Example 6 with AssignationSequence

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

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

the class AddLocalVariableToResult 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 AssignationSequence assignationSequence = AssignationUtils.parseAssignationSequence(configuration, arguments, attributeValue, false);
    final Map<String, Object> localVariables = new HashMap<String, Object>();
    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);
        localVariables.put((varName == null ? null : varName.toString()), varValue);
    }
    element.removeAttribute(attributeName);
    return ProcessorResult.setLocalVariables(localVariables);
}
Also used : IStandardExpression(org.thymeleaf.standard.expression.IStandardExpression) Configuration(org.thymeleaf.Configuration) HashMap(java.util.HashMap) AssignationSequence(org.thymeleaf.standard.expression.AssignationSequence) Assignation(org.thymeleaf.standard.expression.Assignation)

Example 8 with AssignationSequence

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

Assignation (org.thymeleaf.standard.expression.Assignation)8 AssignationSequence (org.thymeleaf.standard.expression.AssignationSequence)8 IStandardExpression (org.thymeleaf.standard.expression.IStandardExpression)6 Configuration (org.thymeleaf.Configuration)4 HashMap (java.util.HashMap)3 TemplateProcessingException (org.thymeleaf.exceptions.TemplateProcessingException)2 Expression (org.thymeleaf.standard.expression.Expression)2 IStandardExpressionParser (org.thymeleaf.standard.expression.IStandardExpressionParser)2 IEngineContext (org.thymeleaf.context.IEngineContext)1 StandardExpressionExecutionContext (org.thymeleaf.standard.expression.StandardExpressionExecutionContext)1