private void writeVariables(JadeModel model, MixinNode mixin, JadeTemplate template) { List <String> names = mixin.getArguments(); List <String> values = arguments; if (names == null) { return; } for (int i = 0; i < names.Count; i++) { String key = names[i]; Object value = null; if (i < values.Count) { value = values[i]; } if (value != null) { try { value = ExpressionHandler.evaluateExpression(values[i], model); } catch (Exception e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } } if (key != null) { model.put(key, value); } } }
public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)// throws JadeCompilerException { MixinNode mixin = model.getMixin(getName()); if (mixin == null) { throw new JadeCompilerException(this, template.getTemplateLoader(), "mixin " + getName() + " is not defined"); } // Clone mixin try { mixin = (MixinNode)mixin.Clone(); } catch (Exception e) { // Can't happen throw; } if (hasBlock()) { List <BlockNode> injectionPoints = getInjectionPoints(mixin.getBlock()); foreach (BlockNode point in injectionPoints) { point.getNodes().AddLast(block); } } model.pushScope(); model.put("block", hasBlock()); writeVariables(model, mixin, template); writeAttributes(model, mixin, template); mixin.getBlock().execute(writer, model, template); model.popScope(); }
private void writeAttributes(JadeModel model, MixinNode mixin, JadeTemplate template) { model.put("attributes", mergeInheritedAttributes(model)); }