Package cn.iver.ext.beetl

Source Code of cn.iver.ext.beetl.BeetlRenderFactory

package cn.iver.ext.beetl;

import cn.iver.common.Const;
import com.jfinal.kit.PathKit;
import com.jfinal.render.IMainRenderFactory;
import com.jfinal.render.Render;
import org.bee.tl.core.GroupTemplate;

import java.io.File;

public class BeetlRenderFactory implements IMainRenderFactory {
    public static String viewExtension = ".html";
    public static GroupTemplate gt = null;

    public BeetlRenderFactory(boolean isLocal) {
        File file = new File(PathKit.getWebRootPath() + Const.BEETL_ROOT_DIR);
        gt = new GroupTemplate(file);
        if (isLocal){
            gt.enableChecker(2);
        } else {
            gt.enableChecker(0);
        }
        gt.setCharset("UTF-8");
        gt.registerFunction("isSame", new IsSameFunction());
        gt.registerFunction("printTime", new PrintTimeFunction());
        gt.setStatementStart("@");
        gt.setStatementEnd(null);
    }

    public Render getRender(String view) {
        return new BeetlRender(gt, view);
    }

    public String getViewExtension() {
        return viewExtension;
    }

}
TOP

Related Classes of cn.iver.ext.beetl.BeetlRenderFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.