Exemplo n.º 1
0
        protected override void WriteElement(DomElement element)
        {
            var frag = element as HxlElement;

            if (frag != null)
            {
                WriteElementFragment(frag);
                return;
            }

            // TODO Missing HTML settings and pretty print semantics
            IHxlElementTemplate template = HxlElementTemplate.ProcessAttributesForTemplate(element, TemplateContext);

            template = template ?? element.GetElementTemplate() ?? HxlElementTemplate.Default;

            template.Render(element, this);
        }
Exemplo n.º 2
0
        internal static IHxlElementTemplate ProcessAttributesForTemplate(DomElement element, HxlTemplateContext templateContext)
        {
            // TODO Cloning array is wasteful (performance)

            // TODO If attributes are added, they aren't considered
            // so if they are server attributes they don't get OnElementRendering_ (rare)

            IHxlElementTemplate template = null;

            // TODO Sort attributes by priority
            // TODO Capture any attribute text output (uncommon)
            foreach (var af in element.Attributes.OfType <HxlAttribute>().ToArray())
            {
                if (af != null)
                {
                    // TODO Probably need to push context
                    template = af.OnElementRendering_(templateContext) ?? template;
                }
            }

            return(template);
        }
Exemplo n.º 3
0
        public static void SetElementTemplate(this DomElement element, IHxlElementTemplate template)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            if (template == null)
            {
                element.RemoveAnnotations <ElementTemplateAnnotation>();
                return;
            }

            var result = element.Annotation <ElementTemplateAnnotation>();

            if (result == null)
            {
                result = new ElementTemplateAnnotation();
                element.AddAnnotation(result);
            }
            result.Template = template;
        }