Package cambridge.model

Examples of cambridge.model.FragmentList


         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();

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

         StringWriter builder = new StringWriter();

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


         ExpressionContext context = new MapExpressionContext();
         context.put("condition", true);

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

         StringWriter builder = new StringWriter();

         for (Fragment f : fragments) {
            f.eval(context, 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);
         assertTrue(fragmentList.get(2) instanceof StaticFragment);

         for (Fragment f : fragmentList) {
            f.eval(context, builder);
         }
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);
         assertTrue(fragmentList.get(2) instanceof StaticFragment);
         assertTrue(fragmentList.get(3) instanceof ExpressionNode);
         assertTrue(fragmentList.get(4) instanceof StaticFragment);

         for (Fragment f : fragmentList) {
            f.eval(context, builder);
         }
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);

         for (Fragment f : fragmentList) {
            f.eval(context, builder);
         }
View Full Code Here

   @Test
   public void testSetDirective() throws Exception {
      TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("set.html"));
      TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
      TemplateDocument doc = parser.parse();
      FragmentList fragmentList = doc.normalize();
      MapExpressionContext context = new MapExpressionContext();
      StringWriter out = new StringWriter();
      for (Fragment f : fragmentList) {
         f.eval(context, out);
      }
View Full Code Here

      try {
         TemplateFactory f = loader.newTemplateFactory("kitchensink.html", new TemplateModifier() {
            public void modifyTemplate(TemplateDocument doc) {

               FragmentList list = new FragmentList(Expressions.cambridgeExpressionLanguage);
               list.add(new StaticFragment("This is a test"));

               try {
                  doc.getElementById("email").addChild(new IncludeNode(loader, "a.html", Expressions.cambridgeExpressionLanguage, "#s"));
               } catch (TemplateLoadingException e) {
                  e.printStackTrace();
View Full Code Here

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

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

      StringWriter builder = new StringWriter();

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

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


         StringWriter builder = new StringWriter();

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

   public void testSelectBefore() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("full.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         TemplateDocument t = parser.parse();
         FragmentList fragments = t.select("before /html/body/div[3]");

         StringWriter builder = new StringWriter();

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

TOP

Related Classes of cambridge.model.FragmentList

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.