Пример #1
0
			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 %}");
			}
Пример #2
0
		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();
		}
Пример #3
0
		public MyFastcgiServer() : base()
		{
			TemplateFactory = new TemplateFactory(new TemplateProviderVirtualFileSystem(new LocalFileSystem(FileUtils.GetExecutableDirectoryPath() + @"\Templates")));

			Posts = new List<Post>();

			Posts.Add(new Post()
			{
				Title = "Sample Title",
				Body = "Sample Body",
			});

			//TemplateProvider.Add("Test.html", "{% block Body %}Ex{% endblock %}");
		}
Пример #4
0
		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());
		}
Пример #5
0
 public TemplateCodeGen(String TemplateString, TemplateFactory TemplateFactory = null)
 {
     this.TemplateFactory = TemplateFactory;
     this.Tokens          = new TokenReader(TemplateTokenizer.Tokenize(new TokenizerStringReader(TemplateString)));
 }
Пример #6
0
 static public Type CompileTemplateCodeTypeByString(String TemplateString, TemplateFactory TemplateFactory = null)
 {
     return((new TemplateCodeGen(TemplateString, TemplateFactory)).GetTemplateCodeType());
 }
Пример #7
0
 static public TemplateCode CompileTemplateCodeByString(String TemplateString, TemplateFactory TemplateFactory = null)
 {
     return((TemplateCode)Activator.CreateInstance(CompileTemplateCodeTypeByString(TemplateString, TemplateFactory), TemplateFactory));
 }
Пример #8
0
        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());
        }
Пример #9
0
		public TemplateCodeGen(String TemplateString, TemplateFactory TemplateFactory = null)
		{
			this.TemplateFactory = TemplateFactory;
			this.Tokens = new TokenReader(TemplateTokenizer.Tokenize(new TokenizerStringReader(TemplateString)));
		}
Пример #10
0
 public static Type CompileTemplateCodeTypeByString(String TemplateString, TemplateFactory TemplateFactory = null)
 {
     return (new TemplateCodeGen(TemplateString, TemplateFactory)).GetTemplateCodeType();
 }
Пример #11
0
 public static TemplateCode CompileTemplateCodeByString(String TemplateString, TemplateFactory TemplateFactory = null)
 {
     return (TemplateCode)Activator.CreateInstance(CompileTemplateCodeTypeByString(TemplateString, TemplateFactory), TemplateFactory);
 }