private void runMap(Dictionary <String, Object> result, JadeModel model, IndentWriter writer, JadeTemplate template) { var keys = result.Keys; if (keys.Count == 0) { executeElseNode(model, writer, template); return; } foreach (String key in keys) { model.put(getValue(), result[key]); model.put(getKey(), key); getBlock().execute(writer, model, template); } }
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); } } }
// throws JadeCompilerException public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template) { 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(); }
public void TestScope() { Assert.AreEqual("world", model.get("hello")); model.pushScope(); model.put("hello", "new world"); Assert.AreEqual("new world", model.get("hello")); model.popScope(); Assert.AreEqual("world", model.get("hello")); }
private void runIterator(IEnumerator iterator, JadeModel model, IndentWriter writer, JadeTemplate template) { int index = 0; if (!iterator.MoveNext()) { executeElseNode(model, writer, template); return; } while (iterator.MoveNext()) { model.put(getValue(), iterator.Current); model.put(getKey(), index); getBlock().execute(writer, model, template); index++; } }
public void Test() { var defaults = new Dictionary<string, object>(); defaults.Add("hello", "world"); model = new JadeModel(defaults); model.put("new", true); Assert.IsFalse(defaults.ContainsKey("new")); Assert.IsTrue(model.ContainsKey("new")); Assert.AreEqual(model.get("hello"), "world"); }
public void Test() { var defaults = new Dictionary <string, object>(); defaults.Add("hello", "world"); model = new JadeModel(defaults); model.put("new", true); Assert.IsFalse(defaults.ContainsKey("new")); Assert.IsTrue(model.ContainsKey("new")); Assert.AreEqual(model.get("hello"), "world"); }
//throws JadeCompilerException public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template) { Object result; try { result = ExpressionHandler.evaluateExpression(value, model); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } model.put(name, result); }
public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template) //throws JadeCompilerException { Object result; try { result = ExpressionHandler.evaluateExpression(value, model); } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } model.put(name, result); }
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)); }
private void runMap(Dictionary<String, Object> result, JadeModel model, IndentWriter writer, JadeTemplate template) { var keys = result.Keys; if (keys.Count == 0) { executeElseNode(model, writer, template); return; } foreach (String key in keys) { model.put(getValue(), result[key]); model.put(getKey(), key); getBlock().execute(writer, model, template); } }
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); } } }