Search in sources :

Example 1 with FileResourceLoader

use of org.beetl.core.resource.FileResourceLoader in project beetl2.0 by javamonkey.

the class MetaCopyTest method main.

public static void main(String[] args) throws Exception {
    String home = System.getProperty("user.dir") + File.separator + "template" + File.separator;
    Configuration cf = Configuration.defaultConfiguration();
    FileResourceLoader rs = new FileResourceLoader(home, cf.getCharset());
    GroupTemplate gt = new GroupTemplate(rs, cf);
    Template t = gt.getTemplate("/helloworld.html");
    Program p = gt.getProgram("/helloworld.html");
    ProgramMetaData old = p.metaData;
    ProgramMetaData copy = old.copy();
    System.out.println("ok");
}
Also used : Program(org.beetl.core.statement.Program) Configuration(org.beetl.core.Configuration) ProgramMetaData(org.beetl.core.statement.ProgramMetaData) FileResourceLoader(org.beetl.core.resource.FileResourceLoader) GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template)

Example 2 with FileResourceLoader

use of org.beetl.core.resource.FileResourceLoader in project beetl2.0 by javamonkey.

the class FilePathRL method main.

public static void main(String[] args) throws Exception {
    String root = System.getProperty("user.dir") + File.separator + "template";
    FileResourceLoader resourceLoader = new FileResourceLoader(root, "utf-8");
    Configuration cfg = Configuration.defaultConfiguration();
    GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
    Template t = gt.getTemplate("/s01/hello.txt");
    String str = t.render();
    System.out.println(str);
}
Also used : Configuration(org.beetl.core.Configuration) FileResourceLoader(org.beetl.core.resource.FileResourceLoader) GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template)

Example 3 with FileResourceLoader

use of org.beetl.core.resource.FileResourceLoader in project beetl2.0 by javamonkey.

the class RegisterFunctionByFile method main.

public static void main(String[] args) throws Exception {
    String root = System.getProperty("user.dir") + File.separator + "template";
    FileResourceLoader resourceLoader = new FileResourceLoader(root, "utf-8");
    Configuration cfg = Configuration.defaultConfiguration();
    GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
    gt.registerFunctionPackage("t", new FunctionPackage());
    Template t = gt.getTemplate("/s32/functionPackage.html");
    String str = t.render();
    System.out.println(str);
}
Also used : Configuration(org.beetl.core.Configuration) FileResourceLoader(org.beetl.core.resource.FileResourceLoader) GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template)

Example 4 with FileResourceLoader

use of org.beetl.core.resource.FileResourceLoader in project beetl2.0 by javamonkey.

the class RegisterFunctionPackage method main.

public static void main(String[] args) throws Exception {
    String root = System.getProperty("user.dir") + File.separator + "template";
    FileResourceLoader resourceLoader = new FileResourceLoader(root, "utf-8");
    Configuration cfg = Configuration.defaultConfiguration();
    GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
    Template t = gt.getTemplate("/s32/pagefunction.html");
    String str = t.render();
    System.out.println(str);
}
Also used : Configuration(org.beetl.core.Configuration) FileResourceLoader(org.beetl.core.resource.FileResourceLoader) GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template)

Example 5 with FileResourceLoader

use of org.beetl.core.resource.FileResourceLoader in project beetl2.0 by javamonkey.

the class IncludeJSPTag method getPrefix.

protected String getPrefix() {
    ResourceLoader rs = ctx.gt.getResourceLoader();
    String loaderRoot = null;
    if (rs instanceof FileResourceLoader) {
        loaderRoot = ((FileResourceLoader) rs).getRoot();
    } else {
        return "";
    }
    File loaderFileRoot = new File(loaderRoot);
    if (loaderFileRoot.equals(root)) {
        return "";
    } else {
        int len = root.getAbsolutePath().length();
        return loaderFileRoot.getAbsolutePath().substring(len);
    }
}
Also used : FileResourceLoader(org.beetl.core.resource.FileResourceLoader) ResourceLoader(org.beetl.core.ResourceLoader) FileResourceLoader(org.beetl.core.resource.FileResourceLoader) File(java.io.File)

Aggregations

FileResourceLoader (org.beetl.core.resource.FileResourceLoader)9 Configuration (org.beetl.core.Configuration)7 GroupTemplate (org.beetl.core.GroupTemplate)7 Template (org.beetl.core.Template)6 File (java.io.File)2 ClasspathResourceLoader (org.beetl.core.resource.ClasspathResourceLoader)2 Test (org.testng.annotations.Test)2 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 ResourceLoader (org.beetl.core.ResourceLoader)1 AllowAllMatcher (org.beetl.core.resource.AllowAllMatcher)1 CompositeResourceLoader (org.beetl.core.resource.CompositeResourceLoader)1 StartsWithMatcher (org.beetl.core.resource.StartsWithMatcher)1 Program (org.beetl.core.statement.Program)1 ProgramMetaData (org.beetl.core.statement.ProgramMetaData)1 LogErrorHandler (org.beetl.ext.nutz.LogErrorHandler)1 IocBean (org.nutz.ioc.loader.annotation.IocBean)1