예제 #1
0
        public override void Render(Parrot.Infrastructure.IParrotWriter writer, IRendererFactory rendererFactory, Nodes.Statement statement, IDictionary <string, object> documentHost, object model)
        {
            var localModel = GetLocalModel(documentHost, statement, model);

            if (localModel is bool && (bool)localModel)
            {
                RenderChildren(writer, statement.Children, rendererFactory, documentHost, base.DefaultChildTag, model);
            }
        }
예제 #2
0
        protected override void CreateTag(Parrot.Infrastructure.IParrotWriter writer, IRendererFactory rendererFactory, IDictionary <string, object> documentHost, object model, Nodes.Statement statement)
        {
            var xhtml = false;

            if (documentHost.ContainsKey("doctype"))
            {
                //we have a registered doctype, is it xml?
                if (documentHost["doctype"].ToString().IndexOf("xhtml", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    //it's xhtml, we need to output cdata
                    xhtml = true;
                }
            }


            string tagName = string.IsNullOrWhiteSpace(statement.Name) ? DefaultChildTag : statement.Name;

            TagBuilder builder = new TagBuilder(tagName);

            //add attributes
            RenderAttributes(rendererFactory, documentHost, model, statement, builder);
            //AppendAttributes(builder, statement.Attributes, documentHost, modelValueProvider);

            writer.Write(builder.ToString(TagRenderMode.StartTag));
            //render children

            if (xhtml)
            {
                writer.Write("//<![CDATA[");
            }

            if (statement.Children.Count > 0)
            {
                RenderChildren(writer, statement, rendererFactory, documentHost, model);
            }

            if (xhtml)
            {
                writer.Write("//]]>");
            }

            writer.Write(builder.ToString(TagRenderMode.EndTag));
        }