Search in sources :

Example 1 with ExpressionSequence

use of org.thymeleaf.standard.expression.ExpressionSequence in project thymeleaf by thymeleaf.

the class AbstractStandardAssertionTagProcessor method doProcess.

@Override
protected final void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) {
    if (StringUtils.isEmptyOrWhitespace(attributeValue)) {
        return;
    }
    final ExpressionSequence expressionSequence = ExpressionSequenceUtils.parseExpressionSequence(context, attributeValue);
    final List<IStandardExpression> expressions = expressionSequence.getExpressions();
    for (final IStandardExpression expression : expressions) {
        final Object expressionResult = expression.execute(context);
        final boolean expressionBooleanResult = EvaluationUtils.evaluateAsBoolean(expressionResult);
        if (!expressionBooleanResult) {
            throw new TemplateAssertionException(expression.getStringRepresentation(), tag.getTemplateName(), tag.getAttribute(attributeName).getLine(), tag.getAttribute(attributeName).getCol());
        }
    }
}
Also used : IStandardExpression(org.thymeleaf.standard.expression.IStandardExpression) ExpressionSequence(org.thymeleaf.standard.expression.ExpressionSequence) TemplateAssertionException(org.thymeleaf.exceptions.TemplateAssertionException)

Aggregations

TemplateAssertionException (org.thymeleaf.exceptions.TemplateAssertionException)1 ExpressionSequence (org.thymeleaf.standard.expression.ExpressionSequence)1 IStandardExpression (org.thymeleaf.standard.expression.IStandardExpression)1