Exemple #1
0
        // 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();
        }
Exemple #2
0
 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"));
 }
Exemple #3
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     try
     {
         model.pushScope();
         while (ExpressionHandler.evaluateBooleanExpression(value, model).Value)
         {
             block.execute(writer, model, template);
         }
         model.popScope();
     }
     catch (ExpressionException e)
     {
         throw new JadeCompilerException(this, template.getTemplateLoader(), e);
     }
 }
Exemple #4
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 //throws JadeCompilerException
 {
     try
     {
         model.pushScope();
         while (ExpressionHandler.evaluateBooleanExpression(value, model).Value)
         {
             block.execute(writer, model, template);
         }
         model.popScope();
     }
     catch (ExpressionException e)
     {
         throw new JadeCompilerException(this, template.getTemplateLoader(), e);
     }
 }
Exemple #5
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     Object result;
     try
     {
         result = ExpressionHandler.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();
 }
Exemple #6
0
        public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
        //throws JadeCompilerException
        {
            Object result;

            try
            {
                result = ExpressionHandler.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();
        }
Exemple #7
0
        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();
        }