Esempio n. 1
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. 2
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. 3
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. 4
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. 5
0
        public void testFullRun()
        {
            Dictionary <String, Object> root = new Dictionary <String, Object>();

            root.Add("hello", "world");
            root.Add("hallo", null);
            JadeModel model = new JadeModel(root);

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

            StringWriter outStream = new StringWriter();

            try
            {
                temp.process(model, outStream);
            }
            catch (JadeCompilerException e)
            {
                Trace.WriteLine(e);
                Assert.Fail();
            }
            outStream.Flush();
            Assert.AreEqual("<div><div>Hi everybody</div></div>", outStream.ToString());
        }
Esempio n. 6
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. 7
0
        // throws JadeCompilerException
        private static String templateToString(JadeTemplate template, Dictionary<String, Object> model)
        {
            JadeModel jadeModel = new JadeModel(model);
            StringWriter writer = new StringWriter();

            template.process(jadeModel, writer);
            return writer.ToString();
        }
Esempio n. 8
0
 //throws JadeCompilerException
 public void renderTemplate(JadeTemplate template, Dictionary<String, Object> model, TextWriter writer)
 {
     JadeModel jadeModel = new JadeModel(sharedVariables);
     foreach (String filterName in filters.Keys)
     {
         jadeModel.addFilter(filterName, filters[filterName]);
     }
     jadeModel.putAll(model);
     template.process(jadeModel, writer);
 }