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

play.templates.Template Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package play.templates;

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

public abstract class Template {

    public String name;
    public String source;

    public abstract void compile();

    /**
     * Starts the rendering process without modifying the args-map
     * @param args map containing data binding info
     * @return the result of the complete rendering
     */
    public String render( Map args ) {
        // starts the internal recursive rendering process with
        // a copy of the passed args-map. This is done
        // to prevent us from polution the users map with
        // template-rendering-specific internal data
        //
        // Since the original args is not poluted it can be used as input
        // to another rendering operation later
        return internalRender( new HashMap(args) );
    }


    /**
     * The internal rendering method - When one templated calls another template,
     * this method is used. The input args-map is constantly being modified, as different
     * templates "communicate" with each other by storing info in the map
     */
    protected abstract String internalRender(Map args);
    
    public String render() {
        return internalRender(new HashMap());
    }

    public String getName() {
        return name;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy