예제 #1
0
        public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template) //throws JadeCompilerException
        {
            try
            {
                Object result = ExpressionHandler.evaluateStringExpression(getValue(), model);
                if (result == null || !buffer)
                {
                    return;
                }
                String str = result.ToString();
                if (escape)
                {
                    str = Utils.escapeHTML(str);
                }
                writer.append(str);

                if (hasBlock())
                {
                    writer.increment();
                    block.execute(writer, model, template);
                    writer.decrement();
                    writer.newline();
                }
            }
            catch (ExpressionException e)
            {
                throw new JadeCompilerException(this, template.getTemplateLoader(), e);
            }
        }
예제 #2
0
파일: Utils.cs 프로젝트: mirannda/Jade4Net
        public static string interpolate(List <Object> prepared, JadeModel model)
        {
            StringBuilder result = new StringBuilder();

            foreach (Object entry in prepared)
            {
                if (entry is String)
                {
                    result.Append(entry);
                }
                else if (entry is ExpressionString)
                {
                    ExpressionString expression  = (ExpressionString)entry;
                    string           stringValue = "";
                    string           value       = ExpressionHandler.evaluateStringExpression(expression.getValue(), model);
                    if (value != null)
                    {
                        stringValue = value;
                    }
                    if (expression.isEscape())
                    {
                        stringValue = escapeHTML(stringValue);
                    }
                    result.Append(stringValue);
                }
            }

            return(result.ToString());
        }