示例#1
0
		async public Task WriteToAsync(IAsyncWriter Stream, String TemplateName, Dictionary<string, object> Scope = null)
		{
			var TemplateCode = await GetTemplateCodeByFileAsync(TemplateName);
			var TextWriter = new NodeTextWriter(Stream);
			var TemplateContext = new TemplateContext(TextWriter, TemplateFactory, new TemplateScope(Scope));
			await TemplateCode.RenderAsync(TemplateContext);
			await TextWriter.FlushAsync();
		}
示例#2
0
 protected void Autoescape(TemplateContext Context, dynamic Expression, EmptyDelegate Block)
 {
     bool OldAutoescape = Context.Autoescape;
     Context.Autoescape = Expression;
     {
         Block();
     }
     Context.Autoescape = OldAutoescape;
 }
示例#3
0
        public void Render(TemplateContext Context)
        {
            Context.RenderingTemplate = this;

            try
            {
                this.LocalRender(Context);
            }
            catch (FinalizeRenderException)
            {
            }
            catch (Exception Exception)
            {
                Context.Output.WriteLine(Exception);
            }
        }
示例#4
0
		public void Render(TemplateContext Context)
		{
			Context.RenderingTemplate = this;

			Exception ProducedException = null;
			try
			{
				this.LocalRender(Context);
			}
			catch (FinalizeRenderException)
			{
			}
			catch (Exception Exception)
			{
				ProducedException = Exception;
			}
			if (ProducedException != null)
			{
				Context.Output.WriteLine(ProducedException.ToString());
				//throw (ProducedException);
			}
		}
示例#5
0
		/*
		async virtual protected Task LocalRenderAsync(TemplateContext Context)
		{
		}
		*/

		/*
		async public Task RenderAsync(TemplateContext Context)
		{
		}
		*/

		async public Task RenderAsync(TemplateContext Context)
		{
			Context.RenderingTemplate = this;

			Exception ProducedException = null;
			try
			{
				await this.LocalRenderAsync(Context);
			}
			catch (FinalizeRenderException)
			{
			}
			catch (Exception Exception)
			{
				ProducedException = Exception;
			}
			if (ProducedException != null)
			{
				await Context.Output.WriteLineAsync(ProducedException.ToString());
				//throw (ProducedException);
			}
		}
示例#6
0
		protected override Task LocalRenderAsync(TemplateContext Context)
		{
 			throw new NotImplementedException();
		}
示例#7
0
		protected void CallParentBlock(String BlockName, TemplateContext Context)
		{
			this.ParentTemplate.GetFirstAscendingBlock(BlockName)(Context);
		}
示例#8
0
		async protected Task CallBlockAsync(String BlockName, TemplateContext Context)
		{
			await Context.RenderingTemplate.GetFirstAscendingBlock(BlockName)(Context);
		}
示例#9
0
		protected void SetAndRenderParentTemplate(String ParentTemplateFileName, TemplateContext Context)
		{
			this.ParentTemplate = Context.TemplateFactory.GetTemplateCodeByFile(ParentTemplateFileName);
			this.ParentTemplate.ChildTemplate = this;
#if NET_4_5
			this.ParentTemplate.LocalRenderAsync(Context);
#else
			this.ParentTemplate.LocalRender(Context);
#endif

			throw (new FinalizeRenderException());
		}
示例#10
0
 protected abstract void LocalRender(TemplateContext Context);
示例#11
0
        /*
         * async protected virtual Task LocalRenderAsync(TemplateContext Context)
         * {
         * }
         */

        /*
         * public async Task RenderAsync(TemplateContext Context)
         * {
         * }
         */

#if NET_4_5
        protected abstract Task LocalRenderAsync(TemplateContext Context);
示例#12
0
 protected void CallParentBlock(String BlockName, TemplateContext Context)
 {
     this.ParentTemplate.GetFirstAscendingBlock(BlockName)(Context);
 }
示例#13
0
 protected void CallBlock(String BlockName, TemplateContext Context)
 {
     Context.RenderingTemplate.GetFirstAscendingBlock(BlockName)(Context);
 }
示例#14
0
 async protected Task CallBlockAsync(String BlockName, TemplateContext Context)
 {
     await Context.RenderingTemplate.GetFirstAscendingBlock(BlockName)(Context);
 }
示例#15
0
		async protected Task ForeachAsync(TemplateContext Context, String VarName, dynamic Expression, EmptyDelegate Iteration, EmptyDelegate Else = null)
		{
			int Index = 0;
			foreach (var Item in DynamicUtils.ConvertToIEnumerable(Expression))
			{
				Context.SetVar("loop", new Dictionary<String, dynamic> {
					{ "index", Index + 1 },
					{ "index0", Index },
				});
				Context.SetVar(VarName, Item);
				await Iteration();
				Index++;
			}

			if (Index == 0)
			{
				if (Else != null) await Else();
			}
		}
示例#16
0
		protected void CallBlock(String BlockName, TemplateContext Context)
		{
			Context.RenderingTemplate.GetFirstAscendingBlock(BlockName)(Context);
		}
示例#17
0
		abstract protected Task LocalRenderAsync(TemplateContext Context);
示例#18
0
		protected abstract void LocalRender(TemplateContext Context);
示例#19
0
		async protected Task SetAndRenderParentTemplateAsync(String ParentTemplateFileName, TemplateContext Context)
		{
			this.ParentTemplate = await Context.TemplateFactory.GetTemplateCodeByFileAsync(ParentTemplateFileName);
			this.ParentTemplate.ChildTemplate = this;
			await this.ParentTemplate.LocalRenderAsync(Context);

			throw (new FinalizeRenderException());
		}
示例#20
0
 protected virtual void LocalRender(TemplateContext Context)
 {
 }