Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        private Object evaluateExpression(ExpressionString attribute, JadeModel model) //throws ExpressionException
        {
            String expression = ((ExpressionString)attribute).getValue();
            Object result     = ExpressionHandler.evaluateExpression(expression, model);

            if (result is ExpressionString)
            {
                return(evaluateExpression((ExpressionString)result, model));
            }
            return(result);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
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();
        }