package me.chyxion.tigon.freemarker;

import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;

/**
 * @version 0.0.1
 * @since 0.0.1
 * @author Shaun Chyxion <br>
 * chyxion@163.com <br>
 * Dec 5, 2014 2:31:39 PM
 */
public class FreeMarkerViewResolverExt extends FreeMarkerViewResolver {
	private static final Logger log = 
		LoggerFactory.getLogger(FreeMarkerViewResolverExt.class);

	/**
	 * {@inheritDoc}
	 */
    @Override
    public View resolveViewName(String viewName, Locale locale) 
    		throws Exception {
    	log.debug("Try To Resolve View Name [{}], Locale [{}] As FreeMarker View.", viewName, locale);
    	return super.resolveViewName(viewName.replaceAll("(?i)(^\\s*ftl\\:)|(\\.ftl\\s*$)", ""), locale);
    }
}
