public void ShouldReturnANewTemplateWhenParsingAString() { var jadeParser = new JadeParser(); var template = jadeParser.Parse(".aString"); Assert.IsNotNull(template); }
private void run(String testName, bool pretty, JadeModel model) { JadeParser parser = null; try { FileTemplateLoader loader = new FileTemplateLoader(TestFileHelper.getCompilerErrorsResourcePath(""), "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 + ".html"); model.addFilter("markdown", new MarkdownFilter()); model.addFilter("plain", new PlainFilter()); String html; try { html = compiler.compileToString(model); Assert.AreEqual(expected.Trim(), html.Trim(), testName); Assert.Fail(); } catch (JadeCompilerException e) { Trace.WriteLine(e); } }
public void ShouldReturnATemplateWithADocTypeAndElementsWhenParsingAStringWithADocTypeAndElements() { var jadeParser = new JadeParser(); var template = jadeParser.Parse("doctype hello\nhello"); Assert.IsNotNull(template.DocType); Assert.AreEqual(1, template.Elements.Count); }
public void ShouldReturnATemplateWithNoDocTypeOrElementsWhenParsingAnEmptyString() { var jadeParser = new JadeParser(); var template = jadeParser.Parse(string.Empty); Assert.IsNull(template.DocType); Assert.AreEqual(0, template.Elements.Count); }
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); }
public IJadeCompileResult Compile(string input) { var lexer = new JadeLexer(); lexer = new JadeLexer(); var tokens = lexer.ReadCode(input); var parser = new JadeParser(); var ast = parser.ParseTokens(tokens); return(CompileFromAst(ast)); }
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); }
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(); }
public void ShouldthrowAnArgumentNullExceptionWhenParsingAStringAndTheStringIsNull() { var jadeParser = new JadeParser(); jadeParser.Parse(null); }