Package groovy.text

Examples of groovy.text.Template


        String uri = webRequest.getAttributes().getTemplateUri(templateName, webRequest.getRequest());
        String contextPath = getStringValue(attrs, "contextPath");
        String pluginName = getStringValue(attrs, "plugin");

        Template t = findAndCacheTemplate(pageScope, templateName, contextPath, pluginName, uri);
        if (t == null) {
            throw new GrailsTagException("Template not found for name [" + templateName + "] and path [" + uri + "]");
        }

        makeTemplate(webRequest, t, attrs, body, out);
View Full Code Here


                            }

                            @Override
                            protected Template updateValue(Template oldValue, Callable<Template> updater, Object cacheRequestObject)
                                    throws Exception {
                                Template t = null;
                                if (scriptSource != null) {
                                    t = groovyPagesTemplateEngine.createTemplate(scriptSource);
                                }
                                if (t == null && scaffoldingTemplateGenerator != null) {
                                    t = generateScaffoldedTemplate(GrailsWebRequest.lookup(), uri);
View Full Code Here

        }
        return out;
    }

    private Template generateScaffoldedTemplate(GrailsWebRequest webRequest, String uri) throws IOException {
        Template t = null;
        Collection<String> controllerActions = scaffoldedActionMap.get(webRequest.getControllerName());
        if (controllerActions != null && controllerActions.contains(webRequest.getActionName())) {
            GrailsDomainClass domainClass = controllerToScaffoldedDomainClassMap.get(webRequest.getControllerName());
            if (domainClass != null) {
                int i = uri.lastIndexOf('/');
View Full Code Here

  @Override
  protected void renderMergedTemplateModel(Map<String, Object> model,
      HttpServletRequest request, HttpServletResponse response) throws Exception {

    Template template = getTemplate(getUrl());
    template.make(model).writeTo(new BufferedWriter(response.getWriter()));
  }
View Full Code Here

     * Needs to be a map rather than a single value to handle overrides.
     * XXX confirm Template is thread safe
     */
    protected ConcurrentHashMap<String,Template> groovyTemplates = new ConcurrentHashMap<String, Template>();
    protected Template groovyTemplate() {
        Template groovyTemplate = groovyTemplates.get(getTemplate());
       
        if (groovyTemplate == null) {
            try {
                groovyTemplate = new SimpleTemplateEngine().createTemplate(getTemplate());
                groovyTemplates.put(getTemplate(), groovyTemplate);
View Full Code Here

        return (String) kp.get("groovyExpression");
    }

    protected ConcurrentHashMap<String,Template> groovyTemplates = new ConcurrentHashMap<String, Template>();
    protected Template groovyTemplate() {
        Template groovyTemplate = groovyTemplates.get(getGroovyExpression());

        if (groovyTemplate == null) {
            try {
                groovyTemplate = new SimpleTemplateEngine().createTemplate("${" + getGroovyExpression() + "}");
                groovyTemplates.put(getGroovyExpression(), groovyTemplate);
View Full Code Here

     * @param key a unique key for the template, such as a file's absolutePath or a URL.
     * @param file a file to be used to determine if the cached template is stale. May be null.
     * @return The cached template, or null if there was no cached entry, or the entry was stale.
     */
    private Template findCachedTemplate(String key, File file) {
        Template template = null;

        /*
         * Test cache for a valid template bound to the key.
         */
        if (verbose) {
View Full Code Here

        try {
            String fileEncoding = (fileEncodingParamVal != null) ? fileEncodingParamVal :
                    System.getProperty(GROOVY_SOURCE_ENCODING);

            reader = fileEncoding == null ? new InputStreamReader(inputStream) : new InputStreamReader(inputStream, fileEncoding);
            Template template = engine.createTemplate(reader);

            cache.put(key, new TemplateCacheEntry(file, template, verbose));

            if (verbose) {
                log("Created and added template to cache. [key=" + key + "] " + cache.get(key));
View Full Code Here

     * @throws ServletException If the request specified an invalid template source file
     */
    protected Template getTemplate(File file) throws ServletException {

        String key = file.getAbsolutePath();
        Template template = findCachedTemplate(key, file);

        //
        // Template not cached or the source file changed - compile new template!
        //
        if (template == null) {
View Full Code Here

     * @throws ServletException If the request specified an invalid template source URL
     */
    protected Template getTemplate(URL url) throws ServletException {

        String key = url.toString();
        Template template = findCachedTemplate(key, null);

        // Template not cached or the source file changed - compile new template!
        if (template == null) {
            try {
                template = createAndStoreTemplate(key, url.openConnection().getInputStream(), null);
View Full Code Here

TOP

Related Classes of groovy.text.Template

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.