All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.mfrey.thymeleaf.extras.cache.ExpressionSupport Maven / Gradle / Ivy

Go to download

A dialect for Thymeleaf that allows you to do partial page caching. Some parts of our webpage will never change during the lifetime of the application or a usersession, but the part should still be dynamic in the beginning. Working with Thymeleaf 3.0.0+ (3.0.0.RELEASE and its dependencies included)

There is a newer version: 3.0.1
Show newest version
package ch.mfrey.thymeleaf.extras.cache;

import org.thymeleaf.Arguments;
import org.thymeleaf.Configuration;
import org.thymeleaf.standard.expression.IStandardExpression;
import org.thymeleaf.standard.expression.IStandardExpressionParser;
import org.thymeleaf.standard.expression.StandardExpressions;

public class ExpressionSupport {

	public static Object getEvaluatedAttributeValue(final Arguments arguments, final String attributeValue) {
		final Configuration configuration = arguments.getConfiguration();
		final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);

		final IStandardExpression expression = expressionParser.parseExpression(configuration, arguments, attributeValue);

		final Object result = expression.execute(configuration, arguments);
		return result;
	}

	public static String getEvaluatedAttributeValueAsString(final Arguments arguments, final String attributeValue) {
		Object result = getEvaluatedAttributeValue(arguments, attributeValue);
		return (result == null ? "" : result.toString());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy