public MyFastcgiServerAsync() { TemplateProvider = new TemplateProviderMemory(); TemplateFactory = new TemplateFactory(TemplateProvider); TemplateProvider.Add("Base.html", "Test{% block Body %}Base{% endblock %}Test"); TemplateProvider.Add("Test.html", "{% extends 'Base.html' %}{% block Body %}Ex{% endblock %}"); //TemplateProvider.Add("Test.html", "{% block Body %}Ex{% endblock %}"); }
static void Main() { //TemplateProvider TemplateProvider = new TemplateProviderVirtualFileSystem(new LocalFileSystem(FileUtils.GetExecutableDirectoryPath(), false)); TemplateProviderMemory TemplateProvider = new TemplateProviderMemory(); TemplateFactory TemplateFactory = new TemplateFactory(TemplateProvider); TemplateProvider.Add("Base.html", "Test{% block Body %}Base{% endblock %}Test"); TemplateProvider.Add("Test.html", "{% extends 'Base.html' %}{% block Body %}Ex{% endblock %}"); //TemplateProvider.Add("Test.html", "{% block Body %}Ex{% endblock %}"); Console.WriteLine(TemplateFactory.GetTemplateCodeByFile("Test.html").RenderToString()); Console.ReadKey(); }
public void TestExecInheritanceWithParentOutside() { TemplateProviderMemory TemplateProvider = new TemplateProviderMemory(); TemplateFactory TemplateFactory = new TemplateFactory(TemplateProvider, OutputGeneratedCode: true); TemplateProvider.Add("Base.html", "Test{% block Body %}Base{% endblock %}Test"); TemplateProvider.Add("Test.html", "{% extends 'Base.html' %}Not{% block Body %}12{% endblock %}{% parent %}Rendered"); Assert.AreEqual("Test1Base2Test", TemplateFactory.GetTemplateCodeByFile("Test.html").RenderToString()); }
public void TestExecBasicInheritance() { TemplateProviderMemory TemplateProvider = new TemplateProviderMemory(); TemplateFactory TemplateFactory = new TemplateFactory(TemplateProvider); TemplateProvider.Add("Base.html", "Test{% block Body %}Base{% endblock %}Test"); TemplateProvider.Add("Test.html", "{% extends 'Base.html' %}Not{% block Body %}Ex{% endblock %}Rendered"); Assert.AreEqual("TestExTest", TemplateFactory.GetTemplateCodeByFile("Test.html").RenderToString()); }