Package play.template2

Examples of play.template2.GTJavaBase


    protected GTRenderingResult renderGTTemplate(Map<String, Object> args) {

        try {

            GTJavaBase gtTemplate = getGTTemplateInstance();
            Monitor monitor = MonitorFactory.start(this.name);
            try {
                gtTemplate.renderTemplate(args);
            } finally {
                monitor.stop();
            }
            return gtTemplate;
View Full Code Here


    @Override
    public Object getProperty(String property) {
        try {
            if (property.equals("actionBridge")) {
                // special object used to resolving actions
                GTJavaBase template = (GTJavaBase)super.getProperty("java_class");
                return new ActionBridge(template.templateLocation.relativePath);
            }
            return super.getProperty(property);
        } catch (MissingPropertyException mpe) {
            return null;
View Full Code Here

        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }

        // get it to check and compile it
        GTJavaBase gtJavaBase = getGTTemplateInstance(templateLocation);

        return new GTTemplate(templateLocation, gtJavaBase);

    }
View Full Code Here

    public static Template load(String key, String source) {

        GTTemplateLocationWithEmbeddedSource tl = new GTTemplateLocationWithEmbeddedSource(key, source);

        // get it or compile it
        GTJavaBase gtJavaBase = getGTTemplateInstance(tl);

        return new GTTemplate(tl, gtJavaBase);
    }
View Full Code Here

        // remove it first
        templateRepo.removeTemplate(tl);

        // get it or compile it
        GTJavaBase gtJavaBase = getGTTemplateInstance(tl);

        return new GTTemplate(tl, gtJavaBase);
    }
View Full Code Here

        GTTemplateLocationWithEmbeddedSource templateLocation = new GTTemplateLocationWithEmbeddedSource(source);

        GTTemplateRepo.TemplateInfo ti = templateRepo.compileTemplate(templateLocation);

        GTJavaBase gtJavaBase = ti.templateInstanceFactory.create(templateRepo);

        return new GTTemplate(templateLocation, gtJavaBase);
    }
View Full Code Here

    @Override
    protected String internalRender(Map<String, Object> args) {


        GTRenderingResult renderingResult = internalGTRender(args);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        renderingResult.writeOutput(out, "utf-8");

        try {
            return new String(out.toByteArray(), "utf-8");
        } catch ( UnsupportedEncodingException e) {
            throw new RuntimeException(e);
View Full Code Here

     * Cleans the specified key from the cache
     * @param key The template key
     */
    public static void cleanCompiledCache(String key) {
        // should only clean cached templates without source
        templateRepo.removeTemplate(new GTTemplateLocation(key));
    }
View Full Code Here

            if ( folder == null) {
                // look for template in working dir.
                File file = new File(queryPath);
                if (file.exists() && file.isFile()) {
                    try {
                        return new GTTemplateLocationReal(VirtualFile.open(file).relativePath(), file.toURI().toURL());
                    } catch (MalformedURLException e) {
                        throw new RuntimeException(e);
                    }
                }
            } else {

                File file = new File ( folder, queryPath);
                if (file.exists() && file.isFile()) {
                    try {
                        return new GTTemplateLocationReal(VirtualFile.open(file).relativePath(), file.toURI().toURL());
                    } catch (MalformedURLException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
       
        // try to find it directly on the app-root before we give up
        VirtualFile tf = Play.getVirtualFile(queryPath);
        if (tf != null && tf.exists() && !tf.isDirectory()) {
            try {
                return new GTTemplateLocationReal(tf.relativePath(), tf.getRealFile().toURI().toURL());
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        }
       
View Full Code Here

        if ( vf == null || !vf.exists() || vf.isDirectory()) {
            return null;
        }

        try {
            return new GTTemplateLocationReal(relativePath, vf.getRealFile().toURI().toURL());
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

TOP

Related Classes of play.template2.GTJavaBase

Copyright © 2018 www.massapicom. 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.