Пример #1
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);
        }
Пример #2
0
 protected void loadInParser(String fileName)
 {
     try
     {
         FileTemplateLoader loader = new FileTemplateLoader(
             TestFileHelper.getParserResourcePath(""), "UTF-8");
         parser = new JadeParser(fileName, loader);
     }
     catch (IOException e)
     {
         Trace.WriteLine(e);
         Assert.Fail("template " + fileName + " was not found");
     }
     root = parser.parse();
 }
Пример #3
0
        private void run(String testName, bool pretty, JadeModel model)
        {
            JadeParser parser = null;

            try
            {
                FileTemplateLoader loader = new FileTemplateLoader(
                    TestFileHelper.getCompilerResourcePath(""), "UTF-8");
                parser = new JadeParser(testName, loader);
            }
            catch (IOException e)
            {
                Trace.WriteLine(e);
            }
            Node root = parser.parse();

            Jade.Compiler.Compiler compiler = new Jade.Compiler.Compiler(root);
            compiler.setPrettyPrint(pretty);
            String expected = readFile(testName + expectedFileNameExtension);

            model.addFilter("markdown", new MarkdownFilter());
            model.addFilter("plain", new PlainFilter());
            model.addFilter("js", new JsFilter());
            model.addFilter("css", new CssFilter());
            model.addFilter("svg", new PlainFilter());
            String html = null;

            try
            {
                html = compiler.compileToString(model);
            }
            catch (JadeCompilerException e)
            {
                Trace.WriteLine(e);
                Assert.Fail();
            }
            Assert.AreEqual(testName, expected.Trim(), html.Trim());
        }