protected LinkedHashMap<String,String> attrs(JadeModel model, JadeTemplate template, LinkedList<Attr> attrs) { ArrayList<String> classes = new ArrayList<String>(); ArrayList<Boolean> classEscaping = new ArrayList<Boolean>(); LinkedHashMap<String,String> newAttributes = new LinkedHashMap<String,String>(); for (Attr attribute : attrs) { try { addAttributesToMap(newAttributes,classes,classEscaping, attribute, model, template); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } } LinkedHashMap<String,String> finalAttributes = new LinkedHashMap<String,String>(); finalAttributes.putAll(newAttributes); if(!classes.isEmpty()){ finalAttributes.put("class", StringUtils.join(classes," ")); } return finalAttributes; }
private String getInterpolatedAttributeValue(String name, Object attribute, boolean escaped, JadeModel model, JadeTemplate template) throws JadeCompilerException { // if (!preparedAttributeValues.containsKey(name)) { // preparedAttributeValues.put(name, Utils.prepareInterpolate((String) attribute, escaped)); // } List<Object> prepared = Utils.prepareInterpolate((String) attribute, escaped); try { return Utils.interpolate(prepared, model,template.getExpressionHandler()); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { String string = Utils.interpolate(preparedValue, model,template.getExpressionHandler()); writer.append(string); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
value = template.getExpressionHandler().evaluateExpression(values.get(i), model); } catch (Throwable e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); value = template.getExpressionHandler().evaluateExpression(values.get(i), model); } catch (Throwable e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e);
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { Object result; try { result = template.getExpressionHandler().evaluateExpression(value, model); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } model.put(name, result); }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { Object result; try { result = template.getExpressionHandler().evaluateExpression(getCode(), model); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } if (result == null) { throw new JadeCompilerException(this, template.getTemplateLoader(), "[" + code + "] has to be iterable but was null"); } model.pushScope(); run(writer, model, result, template); model.popScope(); }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { Filter filter = model.getFilter(getValue()); ArrayList<String> values = new ArrayList<String>(); LinkedList<Node> nodes = textBlock.getNodes(); for (Node node : nodes) { values.add(node.getValue()); } String result = StringUtils.join(values, "\n"); if (filter != null) { result = filter.convert(result, attributes, model); } try { result = Utils.interpolate(result, model, false,template.getExpressionHandler()); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } writer.append(result); }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { boolean skip = false; for (Node when : block.getNodes()) { if (skip || "default".equals(when.getValue()) || checkCondition(model, when,template.getExpressionHandler())) { skip = false; if(when.getBlock()!=null) { when.execute(writer, model, template); break; }else { skip = true; } } } } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { model.pushScope(); while (template.getExpressionHandler().evaluateBooleanExpression(value, model)) { block.execute(writer, model, template); } model.popScope(); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { Object result = template.getExpressionHandler().evaluateExpression(getValue(), model); if (result == null || !buffer) { return; } String string = result.toString(); if (escape) { string = StringEscapeUtils.escapeHtml4(string); } writer.append(string); if (hasBlock()) { writer.increment(); block.execute(writer, model, template); writer.decrement(); writer.newline(); } } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { for (IfConditionNode conditionNode : this.conditions) { try { if (conditionNode.isDefault() || checkCondition(model, conditionNode.getValue(),template.getExpressionHandler()) ^ conditionNode.isInverse()) { conditionNode.getBlock().execute(writer, model, template); return; } } catch (ExpressionException e) { throw new JadeCompilerException(conditionNode, template.getTemplateLoader(), e); } } }
throw new JadeCompilerException(this, template.getTemplateLoader(), "mixin " + getName() + " is not defined");
protected LinkedHashMap<String,String> attrs(JadeModel model, JadeTemplate template, LinkedList<Attr> attrs) { ArrayList<String> classes = new ArrayList<String>(); ArrayList<Boolean> classEscaping = new ArrayList<Boolean>(); LinkedHashMap<String,String> newAttributes = new LinkedHashMap<String,String>(); for (Attr attribute : attrs) { try { addAttributesToMap(newAttributes,classes,classEscaping, attribute, model, template); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } } LinkedHashMap<String,String> finalAttributes = new LinkedHashMap<String,String>(); finalAttributes.putAll(newAttributes); if(!classes.isEmpty()){ finalAttributes.put("class", StringUtils.join(classes," ")); } return finalAttributes; }
private String getInterpolatedAttributeValue(String name, Object attribute, boolean escaped, JadeModel model, JadeTemplate template) throws JadeCompilerException { // if (!preparedAttributeValues.containsKey(name)) { // preparedAttributeValues.put(name, Utils.prepareInterpolate((String) attribute, escaped)); // } List<Object> prepared = Utils.prepareInterpolate((String) attribute, escaped); try { return Utils.interpolate(prepared, model,template.getExpressionHandler()); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { Object result; try { result = template.getExpressionHandler().evaluateExpression(value, model); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } model.put(name, result); }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { String string = Utils.interpolate(preparedValue, model,template.getExpressionHandler()); writer.append(string); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { Object result; try { result = template.getExpressionHandler().evaluateExpression(getCode(), model); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } if (result == null) { throw new JadeCompilerException(this, template.getTemplateLoader(), "[" + code + "] has to be iterable but was null"); } model.pushScope(); run(writer, model, result, template); model.popScope(); }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { model.pushScope(); while (template.getExpressionHandler().evaluateBooleanExpression(value, model)) { block.execute(writer, model, template); } model.popScope(); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { try { boolean skip = false; for (Node when : block.getNodes()) { if (skip || "default".equals(when.getValue()) || checkCondition(model, when,template.getExpressionHandler())) { skip = false; if(when.getBlock()!=null) { when.execute(writer, model, template); break; }else { skip = true; } } } } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
@Override public void execute(IndentWriter writer, JadeModel model, JadeTemplate template) throws JadeCompilerException { for (IfConditionNode conditionNode : this.conditions) { try { if (conditionNode.isDefault() || checkCondition(model, conditionNode.getValue(),template.getExpressionHandler()) ^ conditionNode.isInverse()) { conditionNode.getBlock().execute(writer, model, template); return; } } catch (ExpressionException e) { throw new JadeCompilerException(conditionNode, template.getTemplateLoader(), e); } } }