Package cambridge.parser

Examples of cambridge.parser.TemplateParser


   @Test
   public void testDymnamic() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ParserTest.class.getResourceAsStream("dynamic.html"));
         TemplateParser parser = new TemplateParser(tokenizer);
         Map<String, Object> p = new DefaultTemplateBindings();
         p.put("style", "style");

         TemplateDocument t = parser.parse();

         assertNotNull(t);

         Attribute a = t.locateTag("/div").getAttribute("style");
         assertTrue(a instanceof ComplexAttribute);
View Full Code Here


   public TemplateDocument parseTemplate(InputStream in, String encoding) throws TemplateLoadingException {
      TemplateTokenizer tokenizer = null;
      try {
         tokenizer = new TemplateTokenizer(new InputStreamReader(in, encoding));
         TemplateParser parser = new TemplateParser(tokenizer, this);
         return parser.parse();
      } catch (IOException e) {
         throw new TemplateLoadingException(e);
      } catch (TemplateParsingException e) {
         throw new TemplateLoadingException(e);
      } finally {
View Full Code Here

   public TemplateDocument parseAndCreateTemplateDocument(String templateSource) throws TemplateLoadingException {
      TemplateTokenizer tokenizer = null;
      try {
         tokenizer = new TemplateTokenizer(new StringReader(templateSource));
         TemplateParser parser = new TemplateParser(tokenizer, this);
         return parser.parse();
      } catch (IOException e) {
         throw new TemplateLoadingException(e);
      } catch (TemplateParsingException e) {
         throw new TemplateLoadingException(e);
      } finally {
View Full Code Here

   @Test
   public void testFirst() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(IfElseTest.class.getResourceAsStream("ifelse.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();
         context.put("var1", true);

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

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

   @Test
   public void testSecond() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(IfElseTest.class.getResourceAsStream("ifelse.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();
         context.put("var2", true);

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

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

   @Test
   public void testThird() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(IfElseTest.class.getResourceAsStream("ifelse.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();
         context.put("var3", true);

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

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

   @Test
   public void testFinal() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(IfElseTest.class.getResourceAsStream("ifelse.html"));
         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();
View Full Code Here

   @Test
   public void test() {
      try {
         TemplateTokenizer tokenizer = new TemplateTokenizer(ConditionalAttributeBehaviorTest.class.getResourceAsStream("conditionalattribute.html"));
         TemplateParser parser = new TemplateParser(tokenizer, Expressions.cambridgeExpressionLanguage);
         ExpressionContext context = new MapExpressionContext();
         context.put("condition", true);

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

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

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();

         assertNotNull(t);

         Attribute a = t.locateTag("/div").getAttribute("class");
         assertTrue(a instanceof ComplexAttribute);
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();

         assertNotNull(t);

         Attribute a = t.locateTag("/div").getAttribute("id");
         assertTrue(a instanceof ComplexAttribute);
View Full Code Here

TOP

Related Classes of cambridge.parser.TemplateParser

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.