Package cambridge.model

Examples of cambridge.model.TemplateDocument.normalize()


      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("full.html"));
         TemplateParser parser = new TemplateParser(tokenizer);
         TemplateDocument t = parser.parse();
         assertNotNull(t);
         FragmentList fragments = t.normalize();


         StringWriter builder = new StringWriter();

         for (Fragment f : fragments) {
View Full Code Here


   @Test
   public void testSetDirective() throws Exception {
      TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("set.html"));
      TemplateParser parser = new TemplateParser(tokenizer);
      TemplateDocument doc = parser.parse();
      FragmentList fragmentList = doc.normalize();
      Map<String, Object> prop = new DefaultTemplateBindings();
      StringWriter out = new StringWriter();
      for (Fragment f : fragmentList) {
         f.eval(prop, out);
      }
View Full Code Here

      User user = new User("test", "test@test.com");
      bindings.put("user", user);

      TemplateDocument t = parser.parse();
      assertNotNull(t);
      FragmentList fragments = t.normalize();

      StringWriter builder = new StringWriter();

      for (Fragment f : fragments) {
         f.eval(bindings, builder);
View Full Code Here

         Map<String, Object> bindings = new DefaultTemplateBindings();
         bindings.put("condition", true);

         TemplateDocument t = parser.parse();
         assertNotNull(t);
         FragmentList fragments = t.normalize();

         StringWriter builder = new StringWriter();

         for (Fragment f : fragments) {
            f.eval(bindings, builder);
View Full Code Here

         assertEquals("${class}", node.getSource());

         StringWriter builder = new StringWriter();

         FragmentList fragmentList = t.normalize();

         assertEquals(3, fragmentList.size());

         assertTrue(fragmentList.get(0) instanceof StaticFragment);
         assertTrue(fragmentList.get(1) instanceof ExpressionNode);
View Full Code Here

         assertEquals("and ", st2.toString());
         assertEquals("${b}", node2.getSource());

         StringWriter builder = new StringWriter();

         FragmentList fragmentList = t.normalize();

         assertEquals(5, fragmentList.size());

         assertTrue(fragmentList.get(0) instanceof StaticFragment);
         assertTrue(fragmentList.get(1) instanceof ExpressionNode);
View Full Code Here

         assertEquals("${style}", node1.getSource());

         StringWriter builder = new StringWriter();

         FragmentList fragmentList = t.normalize();

         assertEquals(1, fragmentList.size());

         assertTrue(fragmentList.get(0) instanceof TagNode);
View Full Code Here

         if (doc.getIncludes() != null) {
            includes = l.getFiles(doc.getIncludes());
         }

         fragments = doc.normalize();

      } catch (TemplateLoadingException e) {
         throw new TemplateReloadingException(e);
      } catch (BehaviorInstantiationException e) {
         e.printStackTrace();
View Full Code Here

         modifier.modifyTemplate(document);
      }

      try {
         if (document.getIncludes() != null) {
            return new FileTemplateFactory(this, document.normalize(), file.getRealFile(), encoding, modifier, getFiles(document.getIncludes()), changeDetectionInterval);
         }

         return new FileTemplateFactory(this, document.normalize(), file.getRealFile(), encoding, modifier, null, changeDetectionInterval);
      } catch (BehaviorInstantiationException e) {
         throw new TemplateLoadingException(e);
View Full Code Here

      try {
         if (document.getIncludes() != null) {
            return new FileTemplateFactory(this, document.normalize(), file.getRealFile(), encoding, modifier, getFiles(document.getIncludes()), changeDetectionInterval);
         }

         return new FileTemplateFactory(this, document.normalize(), file.getRealFile(), encoding, modifier, null, changeDetectionInterval);
      } catch (BehaviorInstantiationException e) {
         throw new TemplateLoadingException(e);
      }
   }
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.