Package play.templates

Examples of play.templates.Template.render()


            String contentType = (String) infos.get().get("contentType");
            String bodyHtml = null;
            String bodyText = "";
            try {
                Template templateHtml = TemplateLoader.load(templateName + ".html");
                bodyHtml = templateHtml.render(templateHtmlBinding);
            } catch (TemplateNotFoundException e) {
                if (contentType != null && !contentType.startsWith("text/plain")) {
                    throw e;
                }
            }
View Full Code Here


                }
            }

            try {
                Template templateText = TemplateLoader.load(templateName + ".txt");
                bodyText = templateText.render(templateTextBinding);
            } catch (TemplateNotFoundException e) {
                if (bodyHtml == null && (contentType == null || contentType.startsWith("text/plain"))) {
                    throw e;
                }
            }
View Full Code Here

            params.put("id", id);
            params.put("title", title);
            params.put("sections", sections);
            params.put("html", html);
            Template template = TemplateLoader.load("docviewer-" + templateFile.getName(), IO.readContentAsString(templateFile, "utf-8"));
            String pageContents = template.render(params);
            return pageContents;
        } else {
            //Render plain output
            return html;
        }
View Full Code Here

            response.status = results.passed ? 200 : 500;
            Template resultTemplate = TemplateLoader.load("TestRunner/results.html");
            Map<String, Object> options = new HashMap<String, Object>();
            options.put("test", test);
            options.put("results", results);
            String result = resultTemplate.render(options);
            File testResults = Play.getFile("test-result/" + test + (results.passed ? ".passed" : ".failed") + ".html");
            IO.writeContent(result, testResults);
            try {
                // Write xml output
                options.remove("out");
View Full Code Here

            IO.writeContent(result, testResults);
            try {
                // Write xml output
                options.remove("out");
                resultTemplate = TemplateLoader.load("TestRunner/results-xunit.xml");
                String resultXunit = resultTemplate.render(options);
                File testXunitResults = Play.getFile("test-result/TEST-" + test.substring(0, test.length()-6) + ".xml");
                IO.writeContent(resultXunit, testXunitResults);
            } catch(Exception e) {
                Logger.error(e, "Cannot ouput XML unit output");
            }           
View Full Code Here

            }
            if (testFile.exists()) {
                Template testTemplate = TemplateLoader.load(VirtualFile.open(testFile));
                Map<String, Object> options = new HashMap<String, Object>();
                response.contentType = "text/html";
                renderText(testTemplate.render(options));
            } else {
                renderText("Test not found, %s", testFile);
            }
        }
        if (test.endsWith(".test.html.result")) {
View Full Code Here

        Template resultTemplate = TemplateLoader.load("TestRunner/selenium-results.html");
        Map<String, Object> options = new HashMap<String, Object>();
        options.put("test", test);
        options.put("table", table);
        options.put("result", result);
        String rf = resultTemplate.render(options);
        IO.writeContent(rf, testResults);
        renderText("done");
    }

    public static void mockEmail(String by) {
View Full Code Here

        notFoundIfNull(member);
        Member.addLink(Security.connected(), memberId);
        renderArgs.put("_arg", Member.findByLogin(Security.connected()));
        renderArgs.put("_short", true);
        Template template = TemplateLoader.load(template("tags/member.html"));
        return template.render(renderArgs.data);
    }

    public static void unlink(Long memberId) {
        notFoundIfNull(memberId);
        Member.removeLink(Security.connected(), memberId);
View Full Code Here

      newArgs.putAll(template.getBinding().getVariables());
      newArgs.put("_isInclude", true);
      //dont write to the response.out, need to be escaped before.
      newArgs.remove("out");

      String content = tmpl.render(newArgs);
      out.print(JavaExtensions.escapeJavaScript(content));
    } catch (TemplateNotFoundException e) {
      throw new TemplateNotFoundException(e.getPath(), template.template, fromLine);
    }
  }
View Full Code Here

      for(PDFDocument doc : docs.documents){
        Request request = Http.Request.current();
          String templateName = PDF.resolveTemplateName(doc.template, request, request.format);
            Template template = TemplateLoader.load(templateName);
            doc.args.putAll(args);
        doc.content = template.render(new HashMap<String, Object>(doc.args));
        loadHeaderAndFooter(doc, doc.args);
      }
  }

  private void loadHeaderAndFooter(PDFDocument doc, Map<String, Object> args) throws TemplateNotFoundException {
View Full Code Here

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.