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

com.mitchellbosecke.pebble.spring4.extension.SpringExtension Maven / Gradle / Ivy

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;

import com.mitchellbosecke.pebble.extension.AbstractExtension;
import com.mitchellbosecke.pebble.extension.Function;
import com.mitchellbosecke.pebble.spring4.extension.function.HrefFunction;
import com.mitchellbosecke.pebble.spring4.extension.function.MessageSourceFunction;
import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.GetAllErrorsFunction;
import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.GetFieldErrorsFunction;
import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.GetGlobalErrorsFunction;
import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.HasErrorsFunction;
import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.HasFieldErrorsFunction;
import com.mitchellbosecke.pebble.spring4.extension.function.bindingresult.HasGlobalErrorsFunction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;

import java.util.HashMap;
import java.util.Map;

/**
 * 

* Extension for PebbleEngine to add spring functionality *

* * @author Eric Bussieres */ public class SpringExtension extends AbstractExtension { @Autowired private MessageSource messageSource; @Override public Map getFunctions() { Map functions = new HashMap<>(); functions.put(MessageSourceFunction.FUNCTION_NAME, new MessageSourceFunction(this.messageSource)); functions.put(HasErrorsFunction.FUNCTION_NAME, new HasErrorsFunction()); functions.put(HasGlobalErrorsFunction.FUNCTION_NAME, new HasGlobalErrorsFunction()); functions.put(HasFieldErrorsFunction.FUNCTION_NAME, new HasFieldErrorsFunction()); functions.put(GetAllErrorsFunction.FUNCTION_NAME, new GetAllErrorsFunction(this.messageSource)); functions.put(GetGlobalErrorsFunction.FUNCTION_NAME, new GetGlobalErrorsFunction(this.messageSource)); functions.put(GetFieldErrorsFunction.FUNCTION_NAME, new GetFieldErrorsFunction(this.messageSource)); functions.put(HrefFunction.FUNCTION_NAME, new HrefFunction()); return functions; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy