Package cambridge

Examples of cambridge.TemplateFactory


   public void renderCambridge(int loop, String expressionLanguage) {
      DirectoryTemplateLoader templateLoader = new DirectoryTemplateLoader(
         new File("src/main/cambridgetemplates/" + expressionLanguage), "utf-8", -1);

      TemplateFactory tf = templateLoader.newTemplateFactory("skeleton.html");

      for (int i = 0; i < loop; i++) {
         Template template = tf.createTemplate();
         DataModel.User loggedInUser = model.getLoggedInUser();
         template.setProperty("title", "Entries");
         template.setProperty("loggedInUser", loggedInUser);
         template.setProperty("entries", model.getEntries());
         try {
View Full Code Here


public class RenderCambridgeTemplate extends Result {
   static ConcurrentHashMap<String, TemplateFactory> parsedTemplates = new ConcurrentHashMap<String, TemplateFactory>();
   static PlayTemplateLoader templateLoader = new PlayTemplateLoader();

   public static TemplateFactory getTemplateFactory(String templateName) {
      TemplateFactory factory = parsedTemplates.get(templateName);
      if (factory != null) {
         return factory;
      }

      factory = templateLoader.newTemplateFactory(templateName);

      TemplateFactory f = parsedTemplates.putIfAbsent(templateName, factory);

      return f == null ? factory : f;
   }
View Full Code Here

      this.args = args;
   }

   @Override
   public void apply(Http.Request request, Http.Response response) {
      TemplateFactory tf = getTemplateFactory(templateName);

      final String contentType = MimeTypes.getContentType(templateName, "text/plain");

      Template template = tf.createTemplate(args);

      try {
         OutputStreamWriter out = new OutputStreamWriter(response.out);
         template.printTo(out);
         out.flush();
View Full Code Here

   public void renderCambridge(int loop, String expressionLanguage) {
      DirectoryTemplateLoader templateLoader = new DirectoryTemplateLoader(
         new File("src/main/cambridgetemplates/" + expressionLanguage), "utf-8", -1);

      TemplateFactory tf = templateLoader.newTemplateFactory("skeleton.html", Expressions.cambridgeExpressionLanguage);

      for (int i = 0; i < loop; i++) {
         Template template = tf.createTemplate();
         DataModel.User loggedInUser = model.getLoggedInUser();
         template.setProperty("title", "Entries");
         template.setProperty("loggedInUser", loggedInUser);
         template.setProperty("entries", model.getEntries());
         try {
View Full Code Here

    }

    @Override
    public TemplateFactory getTemplateFactory(String template)
    {
        TemplateFactory templateFactory = cachedTemplates.get(template);
        if (templateFactory != null)
        {
            return templateFactory;
        }
View Full Code Here

            url = url + "." + templateExtension;
        }

        Locale locale = RequestContextUtils.getLocale(request);

        TemplateFactory templateFactory = cambridgeConfig.getTemplateFactory(url);
        Template template = templateFactory.createTemplate(locale);
        ExpressionContext context = template.getContext();
        context.setVariables(model);
        template.printTo(response.getWriter());
    }
View Full Code Here

                "</div>";

        Cambridge.getInstance().bindTag(Cambridge.DefaultNamespaceURI, "form").toProvider(new FormTagProvider());

        FileTemplateLoader loader = new FileTemplateLoader();
        TemplateFactory templateFactory = loader.parseAndCreateTemplateFactory(template, Expressions.cambridgeExpressionLanguage);

        Template t = templateFactory.createTemplate();

        Form form = new Form();
        form.setAction("/test");
        form.setMethod(Form.Method.Post);
        form.setName("testForm");
View Full Code Here

TOP

Related Classes of cambridge.TemplateFactory

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.