@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(); for (Fragment f : fragments) { f.eval(context, builder); } assertEquals(output, builder.toString()); } catch (IOException e) { e.printStackTrace(); } catch (TemplateParsingException e) { e.printStackTrace(); } catch (BehaviorInstantiationException e) { e.printStackTrace(); } catch (TemplateEvaluationException e) { e.printStackTrace(); } }
@Override public String toString() { return "ConditionalAttributeBehavior{" + "expression=" + expression + ", attribute=" + attribute + ", line=" + line + ", col=" + col + '}'; }
ConditionalAttributeBehavior extends ModifyingTagBehavior { @Override public String toString() { return "ConditionalAttributeBehavior{" + "expression=" + expression + ", attribute=" + attribute + ", line=" + line + ", col=" + col + '}'; } }
ConditionalAttributeBehavior extends ModifyingTagBehavior { @Override public String toString() { return "ConditionalAttributeBehavior{" + "expression=" + expression + ", attribute=" + attribute + ", line=" + line + ", col=" + col + '}'; } ConditionalAttributeBehavior(Expression expression, DynamicAttribute attribute, int line, int col); }
ConditionalAttributeBehavior extends ModifyingTagBehavior { @Override public String toString() { return "ConditionalAttributeBehavior{" + "expression=" + expression + ", attribute=" + attribute + ", line=" + line + ", col=" + col + '}'; } ConditionalAttributeBehavior(Expression expression, DynamicAttribute attribute, int line, int col); void modify(ExpressionContext context, ModifyableTag tag); static BehaviorProvider<ConditionalAttributeBehavior> getProvider(); @Override String toString(); }
ConditionalAttributeBehavior extends ModifyingTagBehavior { @Override public String toString() { return "ConditionalAttributeBehavior{" + "expression=" + expression + ", attribute=" + attribute + ", line=" + line + ", col=" + col + '}'; } ConditionalAttributeBehavior(Expression expression, DynamicAttribute attribute, int line, int col); void modify(ExpressionContext context, ModifyableTag tag); static BehaviorProvider<ConditionalAttributeBehavior> getProvider(); @Override String toString();  }