com.mitchellbosecke.pebble.spring4.extension.function.MessageSourceFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pebble-spring4 Show documentation
Show all versions of pebble-spring4 Show documentation
Pebble Integration with Spring 4.x
The newest version!
/*
* Copyright (c) 2013 by Mitchell Bösecke
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package com.mitchellbosecke.pebble.spring4.extension.function;
import com.mitchellbosecke.pebble.extension.Function;
import com.mitchellbosecke.pebble.template.EvaluationContext;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.springframework.context.MessageSource;
/**
*
* Function available to templates in Spring MVC applications in order to resolve message in the
* application context
*
*
* @author Eric Bussieres
*/
public class MessageSourceFunction implements Function {
public static final String FUNCTION_NAME = "message";
private final MessageSource messageSource;
public MessageSourceFunction(MessageSource messageSource) {
this.messageSource = messageSource;
}
@Override
public Object execute(Map args, PebbleTemplate self, EvaluationContext context,
int lineNumber) {
String key = this.extractKey(args);
List