Esempio n. 1
0
        //throws JadeCompilerException
        public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
        {
            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);
            }
        }
Esempio n. 2
0
        public void testEachLoopWithIterableMap()
        {
            Dictionary <string, string> users = new Dictionary <string, string>();

            users.Add("bob", "Robert Smith");
            users.Add("alex", "Alex Supertramp");

            Dictionary <String, Object> root = new Dictionary <String, Object>();

            root.Add("users", users);
            JadeModel model = new JadeModel(root);

            JadeTemplate temp = cfg.getTemplate(getResourcePath("each_loop"));

            StringWriter outStream = new StringWriter();

            try
            {
                temp.process(model, outStream);
            }
            catch (JadeCompilerException e)
            {
                Trace.WriteLine(e);
                Assert.Fail();
            }
            outStream.Flush();
            Assert.AreEqual("<ul><li>Robert Smith</li><li>Alex Supertramp</li></ul>", outStream.ToString());
        }
Esempio n. 3
0
        //throws JadeCompilerException
        public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
        {
            String name = getValue();
            if (name == null)
            {
                name = "5";
            }
            String doctypeLine = Doctypes.get(name);
            if (doctypeLine == null)
            {
                doctypeLine = "<!DOCTYPE " + name + ">";
            }

            if (doctypeLine.StartsWith("<?xml"))
            {
                template.setMode(Jade4Net.Mode.XML);
            }
            else if (doctypeLine.Equals("<!DOCTYPE html>"))
            {
                template.setMode(Jade4Net.Mode.HTML);
            }
            else
            {
                template.setMode(Jade4Net.Mode.XHTML);
            }

            writer.append(doctypeLine);
        }
Esempio n. 4
0
 private void executeElseNode(JadeModel model, IndentWriter writer, JadeTemplate template)
 {
     if (elseNode != null)
     {
         elseNode.execute(writer, model, template);
     }
 }
Esempio n. 5
0
 private void executeElseNode(JadeModel model, IndentWriter writer, JadeTemplate template)
 {
     if (elseNode != null)
     {
         elseNode.execute(writer, model, template);
     }
 }
Esempio n. 6
0
        public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
        //throws JadeCompilerException
        {
            String name = getValue();

            if (name == null)
            {
                name = "5";
            }
            String doctypeLine = Doctypes.get(name);

            if (doctypeLine == null)
            {
                doctypeLine = "<!DOCTYPE " + name + ">";
            }

            if (doctypeLine.StartsWith("<?xml"))
            {
                template.setMode(Jade4Net.Mode.XML);
            }
            else if (doctypeLine.Equals("<!DOCTYPE html>"))
            {
                template.setMode(Jade4Net.Mode.HTML);
            }
            else
            {
                template.setMode(Jade4Net.Mode.XHTML);
            }

            writer.append(doctypeLine);
        }
Esempio n. 7
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     foreach (Node node in getNodes())
     {
         node.execute(writer, model, template);
     }
 }
Esempio n. 8
0
        public void test()
        {
            var folder = new DirectoryInfo(TestFileHelper.getOriginalResourcePath(""));
            var files  = folder.EnumerateFiles("*.jade", SearchOption.TopDirectoryOnly);

            JadeConfiguration jade = new JadeConfiguration();

            jade.setMode(Jade4Net.Mode.XHTML); // original jade uses xhtml by default
            jade.setFilter("plain", new PlainFilter());
            jade.setFilter("cdata", new CDATAFilter());

            foreach (var file in files)
            {
                JadeTemplate template = jade.getTemplate(file.FullName);
                TextWriter   writer   = new StringWriter();
                jade.renderTemplate(template, new Dictionary <String, Object>(), writer);
                String html = writer.ToString();

                String expected = File.ReadAllText(file.FullName.Replace(".jade", ".html"));
                // Trace.WriteLine("\n>> " + file.getName());
                // Trace.WriteLine(html);
                // Trace.WriteLine("-- " + file.getName());
                // Trace.WriteLine(expected);
                // Trace.WriteLine("<< " + file.getName());

                if (Array.IndexOf(manualCompared, file.Name.Replace(".jade", "")) >= 0)
                {
                    Assert.AreEqual(file.FullName, expected, html);
                }
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
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();
        }
Esempio n. 11
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);
                }
            }
        }
Esempio n. 12
0
        public void testRootNode()
        {
            JadeConfiguration config   = new JadeConfiguration();
            JadeTemplate      template = config.getTemplate(getParserResourcePath("assignment"));

            Assert.IsNotNull(template.getRootNode());
        }
Esempio n. 13
0
        public static String render(TextReader reader, String filename, Dictionary <String, Object> model, bool pretty)
        //throws IOException, JadeCompilerException
        {
            JadeTemplate template = getTemplate(reader, filename);

            return(render(template, model, pretty));
        }
Esempio n. 14
0
        public static void render(String filename, Dictionary <String, Object> model, TextWriter writer, bool pretty)
        // throws IOException,JadeCompilerException
        {
            JadeTemplate template = getTemplate(filename);

            template.setPrettyPrint(pretty);
            template.process(new JadeModel(model), writer);
        }
Esempio n. 15
0
        public static String render(String filename, Dictionary <String, Object> model, bool pretty)
        // throws IOException, JadeCompilerException
        {
            JadeTemplate template = getTemplate(filename);

            template.setPrettyPrint(pretty);
            return(templateToString(template, model));
        }
Esempio n. 16
0
        public String renderTemplate(JadeTemplate template, Dictionary <String, Object> model)
        //throws JadeCompilerException
        {
            StringWriter writer = new StringWriter();

            renderTemplate(template, model, writer);
            return(writer.ToString());
        }
Esempio n. 17
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 //throws JadeCompilerException
 {
     foreach (Node node in getNodes())
     {
         node.execute(writer, model, template);
     }
 }
Esempio n. 18
0
        private static String templateToString(JadeTemplate template, Dictionary <String, Object> model)
        // throws JadeCompilerException
        {
            JadeModel    jadeModel = new JadeModel(model);
            StringWriter writer    = new StringWriter();

            template.process(jadeModel, writer);
            return(writer.ToString());
        }
Esempio n. 19
0
        public void testPrettyPrint()
        {
            JadeConfiguration config = new JadeConfiguration();

            config.setPrettyPrint(true);
            JadeTemplate template = config.getTemplate(getParserResourcePath("assignment"));

            Assert.IsTrue(template.isPrettyPrint());
        }
Esempio n. 20
0
        private static JadeTemplate createTemplate(String filename, TemplateLoader loader) // throws IOException
        {
            JadeParser   jadeParser = new JadeParser(filename, loader);
            Node         root       = jadeParser.parse();
            JadeTemplate template   = new JadeTemplate();

            template.setTemplateLoader(loader);
            template.setRootNode(root);
            return(template);
        }
Esempio n. 21
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)// throws JadeCompilerException
 {
     if (!isBuffered())
     {
         return;
     }
     writer.newline();
     writer.append("<!--");
     writer.append(value);
     writer.append("-->");
 }
Esempio n. 22
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 //throws JadeCompilerException
 {
     if (hasBlock())
     {
         model.setMixin(getName(), this);
     }
     else
     {
         base.execute(writer, model, template);
     }
 }
Esempio n. 23
0
        public void renderTemplate(JadeTemplate template, Dictionary <String, Object> model, TextWriter writer)
        //throws JadeCompilerException
        {
            JadeModel jadeModel = new JadeModel(sharedVariables);

            foreach (String filterName in filters.Keys)
            {
                jadeModel.addFilter(filterName, filters[filterName]);
            }
            jadeModel.putAll(model);
            template.process(jadeModel, writer);
        }
Esempio n. 24
0
        public static String render(Uri url, Dictionary <String, Object> model, bool pretty)
        // throws IOException, JadeCompilerException
        {
            string contents;

            using (var wc = new WebClient())
                contents = wc.DownloadString(url);
            var          reader   = new StringReader(contents);
            JadeTemplate template = getTemplate(reader, url.AbsoluteUri);

            return(render(template, model, pretty));
        }
Esempio n. 25
0
 //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);
 }
Esempio n. 26
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 //throws JadeCompilerException
 {
     try
     {
         String str = Utils.interpolate(preparedValue, model);
         writer.append(str);
     }
     catch (ExpressionException e)
     {
         throw new JadeCompilerException(this, template.getTemplateLoader(), e);
     }
 }
Esempio n. 27
0
        public void testCache()
        {
            JadeConfiguration config = new JadeConfiguration();

            config.setCaching(true);
            JadeTemplate template = config.getTemplate(getParserResourcePath("assignment"));

            Assert.IsNotNull(template);
            JadeTemplate template2 = config.getTemplate(getParserResourcePath("assignment"));

            Assert.IsNotNull(template2);
            Assert.AreEqual(template, template2);
        }
Esempio n. 28
0
 private void run(IndentWriter writer, JadeModel model, Object result, JadeTemplate template)
 {
     if (result is IEnumerable) {
         runIterator(((IEnumerable) result).GetEnumerator(), model, writer, template);
     } else if (result.GetType().IsArray)
     {
         var iterator = ((IEnumerable)result).GetEnumerator();
         runIterator(iterator, model, writer, template);
     }
     else if (result is Dictionary<String, Object>) {
         runMap((Dictionary<String, Object>)result, model, writer, template);
     }
 }
Esempio n. 29
0
        private JadeTemplate createTemplate(String name)
        //throws JadeException, IOException
        {
            JadeTemplate template = new JadeTemplate();

            JadeParser parser = new JadeParser(name, templateLoader);
            Node       root   = parser.parse();

            template.setTemplateLoader(templateLoader);
            template.setRootNode(root);
            template.setPrettyPrint(prettyPrint);
            template.setMode(getMode());
            return(template);
        }
Esempio n. 30
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);
        }
Esempio n. 31
0
        public void testExceptionOnUnknowwTemplate()
        {
            JadeConfiguration config   = new JadeConfiguration();
            JadeTemplate      template = null;

            try
            {
                template = config.getTemplate("UNKNOWN_PATH");
                Assert.Fail("Did expect TemplatException!");
            }
            catch (IOException ignore)
            {
            }
            Assert.IsNull(template);
        }
Esempio n. 32
0
 private void run(IndentWriter writer, JadeModel model, Object result, JadeTemplate template)
 {
     if (result is IEnumerable)
     {
         runIterator(((IEnumerable)result).GetEnumerator(), model, writer, template);
     }
     else if (result.GetType().IsArray)
     {
         var iterator = ((IEnumerable)result).GetEnumerator();
         runIterator(iterator, model, writer, template);
     }
     else if (result is Dictionary <String, Object> )
     {
         runMap((Dictionary <String, Object>)result, model, writer, template);
     }
 }
Esempio n. 33
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);
     }
 }
Esempio n. 34
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);
     }
 }
Esempio n. 35
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     try
     {
         foreach (CaseConditionNode caseConditionNode in caseConditionNodes)
         {
             if (caseConditionNode.isDefault() || checkCondition(model, caseConditionNode))
             {
                 caseConditionNode.execute(writer, model, template);
                 break;
             }
         }
     }
     catch (ExpressionException e)
     {
         throw new JadeCompilerException(this, template.getTemplateLoader(), e);
     }
 }
Esempio n. 36
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     foreach (IfConditionNode conditionNode in this.conditions)
     {
         try
         {
             if (conditionNode.isDefault() || checkCondition(model, conditionNode.getValue()) ^ conditionNode.isInverse())
             {
                 conditionNode.getBlock().execute(writer, model, template);
                 return;
             }
         }
         catch (ExpressionException e)
         {
             throw new JadeCompilerException(conditionNode, template.getTemplateLoader(), e);
         }
     }
 }
Esempio n. 37
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     var filter = model.getFilter(getValue());
     String result = textBlock.getValue();
     if (filter != null)
     {
         result = filter.convert(result, attributes, model);
     }
     try
     {
         result = Utils.interpolate(result, model, false);
     }
     catch (ExpressionException e)
     {
         throw new JadeCompilerException(this, template.getTemplateLoader(), e);
     }
     writer.append(result);
 }
Esempio n. 38
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 //throws JadeCompilerException
 {
     foreach (IfConditionNode conditionNode in this.conditions)
     {
         try
         {
             if (conditionNode.isDefault() || checkCondition(model, conditionNode.getValue()) ^ conditionNode.isInverse())
             {
                 conditionNode.getBlock().execute(writer, model, template);
                 return;
             }
         }
         catch (ExpressionException e)
         {
             throw new JadeCompilerException(conditionNode, template.getTemplateLoader(), e);
         }
     }
 }
Esempio n. 39
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 //throws JadeCompilerException
 {
     try
     {
         foreach (CaseConditionNode caseConditionNode in caseConditionNodes)
         {
             if (caseConditionNode.isDefault() || checkCondition(model, caseConditionNode))
             {
                 caseConditionNode.execute(writer, model, template);
                 break;
             }
         }
     }
     catch (ExpressionException e)
     {
         throw new JadeCompilerException(this, template.getTemplateLoader(), e);
     }
 }
Esempio n. 40
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();
 }
Esempio n. 41
0
 // throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     if (!isBuffered())
     {
         return;
     }
     writer.newline();
     if (value.StartsWith("if"))
     {
         writer.append("<!--[" + value + "]>");
         block.execute(writer, model, template);
         writer.append("<![endif]-->");
     }
     else
     {
         writer.append("<!--" + value);
         block.execute(writer, model, template);
         writer.append("-->");
     }
 }
Esempio n. 42
0
        public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
        //throws JadeCompilerException
        {
            var    filter = model.getFilter(getValue());
            String result = textBlock.getValue();

            if (filter != null)
            {
                result = filter.convert(result, attributes, model);
            }
            try
            {
                result = Utils.interpolate(result, model, false);
            }
            catch (ExpressionException e)
            {
                throw new JadeCompilerException(this, template.getTemplateLoader(), e);
            }
            writer.append(result);
        }
Esempio n. 43
0
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)// throws JadeCompilerException
 {
     if (!isBuffered())
     {
         return;
     }
     writer.newline();
     if (value.StartsWith("if"))
     {
         writer.append("<!--[" + value + "]>");
         block.execute(writer, model, template);
         writer.append("<![endif]-->");
     }
     else
     {
         writer.append("<!--" + value);
         block.execute(writer, model, template);
         writer.append("-->");
     }
 }
Esempio n. 44
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     writer.newline();
     writer.append("<");
     writer.append(name);
     writer.append(Attributes(model, template));
     if (isTerse(template))
     {
         writer.append(">");
         return;
     }
     if (isSelfClosing(template) || (selfClosing && isEmpty()))
     {
         writer.append("/>");
         return;
     }
     writer.append(">");
     if (hasTextNode())
     {
         textNode.execute(writer, model, template);
     }
     if (hasBlock())
     {
         writer.increment();
         block.execute(writer, model, template);
         writer.decrement();
         writer.newline();
     }
     if (hasCodeNode())
     {
         codeNode.execute(writer, model, template);
     }
     writer.append("</");
     writer.append(name);
     writer.append(">");
 }
Esempio n. 45
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     writer.append(value);
 }
Esempio n. 46
0
 public abstract void execute(IndentWriter writer, JadeModel model, JadeTemplate template);
Esempio n. 47
0
 //throws JadeCompilerException
 public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template)
 {
     block.execute(writer, model, template);
 }
Esempio n. 48
0
 // throws JadeCompilerException
 public static String render(JadeTemplate template, Dictionary<String, Object> model, bool pretty)
 {
     template.setPrettyPrint(pretty);
     return templateToString(template, model);
 }
Esempio n. 49
0
 // throws JadeCompilerException
 public static void render(JadeTemplate template, Dictionary<String, Object> model, TextWriter writer, bool pretty)
 {
     template.setPrettyPrint(pretty);
     template.process(new JadeModel(model), writer);
 }
Esempio n. 50
0
 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);
     }
 }
Esempio n. 51
0
        // throws ExpressionException
        private String getAttributeString(String name, Object attribute, JadeModel model, JadeTemplate template)
        {
            String value = null;
            if (attribute is String) {
                value = getInterpolatedAttributeValue(name, attribute, model, template);
            } else if (attribute is bool) {
                if ((bool)attribute)
                {
                    value = name;
                }
                else
                {
                    return "";
                }
                if (template.isTerse())
                {
                    value = null;
                }
            } else if (attribute is ExpressionString) {
                Object expressionValue = evaluateExpression((ExpressionString)attribute, model);
                if (expressionValue == null)
                {
                    return "";
                }
                // TODO: refactor
                if (expressionValue is bool) {
                    if ((bool)expressionValue)
                    {
                        value = name;
                    }
                    else
                    {
                        return "";
                    }
                    if (template.isTerse())
                    {
                        value = null;
                    }
                } else {
                    value = expressionValue.ToString();
                    value = Utils.escapeHTML(value);
                }
            } else {
                return "";
            }

            StringBuilder sb = new StringBuilder();
            if (name != null)
            {
                sb.Append(" ").Append(name);
                if (value != null)
                {
                    sb.Append("=").Append('"');
                    sb.Append(value);
                    sb.Append('"');
                }
            }
            return sb.ToString();
        }
Esempio n. 52
0
 //throws JadeCompilerException
 private String getInterpolatedAttributeValue(String name, Object attribute, JadeModel model, JadeTemplate template)
 {
     if (!preparedAttributeValues.ContainsKey(name))
     {
         preparedAttributeValues.Add(name, Utils.prepareInterpolate((String)attribute, true));
     }
     List<Object> prepared = preparedAttributeValues[name];
     try
     {
         return Utils.interpolate(prepared, model);
     }
     catch (ExpressionException e)
     {
         throw new JadeCompilerException(this, template.getTemplateLoader(), e);
     }
 }
Esempio n. 53
0
 // throws JadeCompilerException
 public static String render(JadeTemplate template, Dictionary<String, Object> model)
 {
     return render(template, model, false);
 }
Esempio n. 54
0
 public void setTemplate(JadeTemplate jadeTemplate)
 {
     this.template = jadeTemplate;
 }
Esempio n. 55
0
        private String Attributes(JadeModel model, JadeTemplate template)
        {
            StringBuilder sb = new StringBuilder();

            Dictionary<String, Object> mergedAttributes = mergeInheritedAttributes(model);

            foreach (var entry in mergedAttributes)
            {
                try
                {
                    sb.Append(getAttributeString(entry.Key, entry.Value, model, template));
                }
                catch (ExpressionException e)
                {
                    throw new JadeCompilerException(this, template.getTemplateLoader(), e);
                }
            }

            return sb.ToString();
        }
Esempio n. 56
0
 public bool isTerse(JadeTemplate template)
 {
     return isSelfClosing(template) && template.isTerse();
 }
Esempio n. 57
0
 // throws JadeCompilerException
 public static void render(JadeTemplate template, Dictionary<String, Object> model, TextWriter writer)
 {
     render(template, model, writer, false);
 }
Esempio n. 58
0
        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++;
            }
        }
Esempio n. 59
0
 public bool isSelfClosing(JadeTemplate template)
 {
     return !template.isXml()
         && Array.FindIndex(selfClosingTags, s => s == name) >= 0;
 }
Esempio n. 60
0
 public TagNodeTest()
 {
     tagNode = new TagNode();
     template = new JadeTemplate();
     template.setMode(Jade4Net.Mode.XHTML);
 }