Package cambridge.parser

Examples of cambridge.parser.TemplateTokenizer


*/
public class ComplexAttributeTest {
   @Test
   public void testBasic() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("basic.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);

         ExpressionContext context = new MapExpressionContext();
         context.put("class", "test");
         TemplateDocument t = parser.parse();
View Full Code Here


   }

   @Test
   public void testComplex() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("complex.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();
         context.put("a", "AAA");
         context.put("b", "BBB");
         TemplateDocument t = parser.parse();
View Full Code Here

   }

   @Test
   public void testDymnamic() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("dynamic.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();

         context.put("style", "style");
View Full Code Here

* Time: 9:17:38 AM
*/
public class SetDirectiveTest {
   @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();
View Full Code Here

   private final String out = "<div>friend1</div>";

   @Test
   public void testWithBehavior() throws Exception {
      TemplateTokenizer tokenizer = new TemplateTokenizer(ConditionalAttributeBehaviorTest.class.getResourceAsStream("withbehavior.html"));
      TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
      ExpressionContext context = new MapExpressionContext();

      User user = new User("test", "test@test.com");
      context.put("user", user);
View Full Code Here

      try {
         TemplateFactory f = loader.newTemplateFactory("a.html", new TemplateModifier() {
            public void modifyTemplate(TemplateDocument doc) {
               try {
                  TemplateTokenizer tokenizer = new TemplateTokenizer(new InputStreamReader(new FileInputStream("b.html"), "UTF-8"));
                  TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
                  TemplateDocument document = parser.parse();

                  Tag tag = document.getElementsByTagName("body").get(0);
                  Tag bodyTag = doc.getElementsByTagName("body").get(0);
View Full Code Here

      "\n";

   @Test
   public void testFull() {
      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();
View Full Code Here

   }

   @Test
   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();
View Full Code Here

   }

   @Test
   public void testSelectAfter() {
      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("after /html/body/div[3]");

         StringWriter builder = new StringWriter();
View Full Code Here

   }

   @Test
   public void testSelectInside() {
      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("inside /html/body");

         StringWriter builder = new StringWriter();
View Full Code Here

TOP

Related Classes of cambridge.parser.TemplateTokenizer

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.