예제 #1
0
        public override Task GetContentItemAspectAsync(ContentItemAspectContext context, LiquidPart part)
        {
            return(context.ForAsync <BodyAspect>(async bodyAspect =>
            {
                try
                {
                    var model = new LiquidPartViewModel()
                    {
                        LiquidPart = part,
                        ContentItem = part.ContentItem
                    };

                    var result = await _liquidTemplateManager.RenderHtmlContentAsync(part.Liquid, _htmlEncoder, model,
                                                                                     new Dictionary <string, FluidValue>()
                    {
                        ["ContentItem"] = new ObjectValue(model.ContentItem)
                    });

                    bodyAspect.Body = result;
                }
                catch
                {
                    bodyAspect.Body = HtmlString.Empty;
                }
            }));
        }
예제 #2
0
        private ShapeBinding BuildShapeBinding(string shapeType, Template template)
        {
            return(new ShapeBinding()
            {
                BindingName = shapeType,
                BindingSource = shapeType,
                BindingAsync = async displayContext =>
                {
                    var content = await _liquidTemplateManager.RenderHtmlContentAsync(template.Content, _htmlEncoder, displayContext.Value);

                    return content;
                }
            });
        }
 public static Task <IHtmlContent> RenderHtmlContentAsync(this ILiquidTemplateManager manager, string template, TextEncoder encoder, IEnumerable <KeyValuePair <string, FluidValue> > properties)
 => manager.RenderHtmlContentAsync(template, encoder, model: null, properties);
 public static Task <IHtmlContent> RenderHtmlContentAsync(this ILiquidTemplateManager manager, string template, TextEncoder encoder, object model)
 => manager.RenderHtmlContentAsync(template, encoder, model, properties: null);