internal static void Render(DomElement element, string name, string layoutName, HxlWriter hxlOutput) { var templateContext = hxlOutput.TemplateContext; var pc = templateContext.FindPlaceholderContent(name); DomElement content; if (pc == null) { content = element; } else { content = pc.Element; layoutName = pc.Layout; MergeAttributes(content, element); } var attr = element.Attributes["class"]; if (attr == null) { element.Attribute("class", "app-placeholder"); } else { AttributeAppend(attr, "app-placeholder"); } element.Attribute("data-placeholder", name); element.Attribute("data-layout", layoutName); // TODO Skip over single-page elements that were disabled // TODO Output correct locations var output = hxlOutput.BaseWriter; // TODO We always render element - should attribute selection be allowed to choose another element template? HxlElementTemplate.ProcessAttributesForTemplate(element, templateContext); HxlElementTemplate.RenderElementStart(element, output); hxlOutput.Write(content.ChildNodes); HxlElementTemplate.RenderElementEnd(element, output); }
public void Attributes_test_detached_element_temporary_attributes() { // It is possible that DomElement might be created outside of DomDocument such as this, // or that initialization order of element might cause attributes to be created DomElement e = new DomElement("detached"); e.Attribute("hello", "world"); Assert.Equal("world", e.Attribute("hello")); DomDocument doc = new DomDocument(); doc.Append(e); Assert.Equal("world", e.Attribute("hello")); e.Attribute("hello", "earth"); Assert.Equal("hello", e.Attributes[0].LocalName); Assert.Equal("earth", e.Attributes[0].Value); }
public void Render(DomElement element, HxlWriter output) { var eti = new HxlElementTemplateInfo(element.Name, element.Attribute("class")); var services = ServiceProvider.Compose( ServiceProvider.Current, ServiceProvider.FromValue(eti)); var template = output.TemplateContext.TemplateFactory.CreateTemplate(_name, _type, services); if (template == null) { // TODO Missing line number throw HxlFailure.CannotFindMatchingTemplate(_type, _name, -1, -1); } var context = output.TemplateContext.CreateChildContext(template); context.Data.Add("element", element); template.Transform(output.BaseWriter, context); }
internal static string GetImpliedPlaceholderName(DomElement e, string explicitName) { if (!string.IsNullOrWhiteSpace(explicitName)) { return(explicitName); } if (e == null) { return(null); } string id = e.Attribute("id"); if (!string.IsNullOrEmpty(id)) { return(id); } return(e.NodeName); }
public override bool Matches(DomElement root, DomElement element) { return !value.Equals(element.Attribute(name), StringComparison.OrdinalIgnoreCase); }
public override bool Matches(DomElement root, DomElement element) { return element.HasAttribute(name) && pattern.IsMatch(element.Attribute(name)); }
public override bool Matches(DomContainer root, DomElement element) { return(element.HasAttribute(name) && element.Attribute(name).EndsWith(value, StringComparison.OrdinalIgnoreCase)); // value is lower case }
public override bool Matches(DomContainer root, DomElement element) { return(element.HasAttribute(name) && element.Attribute(name).ToLower().Contains(value)); // value is lower case }
public override bool Matches(DomContainer root, DomElement element) { return(!value.Equals(element.Attribute(name), StringComparison.OrdinalIgnoreCase)); }
public override bool Matches(DomContainer root, DomElement element) { return(element.HasAttribute(name) && pattern.IsMatch(element.Attribute(name))); }
public override bool Matches(DomElement root, DomElement element) { return element.HasAttribute(name) && element.Attribute(name).EndsWith(value, StringComparison.OrdinalIgnoreCase); // value is lower case }
public override bool Matches(DomElement root, DomElement element) { return element.HasAttribute(name) && element.Attribute(name).ToLower().Contains(value); // value is lower case }