本文整理汇总了C#中HtmlTag.Add方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.Add方法的具体用法?C# HtmlTag.Add怎么用?C# HtmlTag.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HtmlDocument
public HtmlDocument()
{
RootTag = new HtmlTag("html");
DocType = "<!DOCTYPE html>";
Head = RootTag.Add("head");
_title = Head.Add("title");
Body = RootTag.Add("body");
Last = Body;
}
示例2: Transform
public string Transform(Topic current, string data)
{
var ol = new HtmlTag("ol").AddClass("breadcrumb");
current.Ancestors().Each(x =>
{
ol.Add("li/a").Attr("href", _resolver.ToUrl(current, x)).Text(x.Title);
});
ol.Add("li").AddClass("active").Text(current.Title);
return ol.ToString();
}
示例3: add_returns_the_newly_created_child_tag
public void add_returns_the_newly_created_child_tag()
{
var original = new HtmlTag("div");
var child = original.Add("span");
child.ToString().ShouldEqual("<span></span>");
original.ToString().ShouldEqual("<div><span></span></div>");
}
示例4: add_and_return_a_child_tag_by_type
public void add_and_return_a_child_tag_by_type()
{
var original = new HtmlTag("div");
var child = original.Add<HiddenTag>();
child.ToString().ShouldEqual("<input type=\"hidden\" />");
original.ToString().ShouldEqual("<div><input type=\"hidden\" /></div>");
}
示例5: parent_property_is_set_correctly_using_add
public void parent_property_is_set_correctly_using_add()
{
var tag = new HtmlTag("div");
var child = tag.Add("span");
tag.ShouldEqual(child.Parent);
tag.Children[0].ShouldEqual(child);
}
示例6: add_multiple_levels_of_nesting
public void add_multiple_levels_of_nesting()
{
var tag = new HtmlTag("table");
tag.Add("tbody/tr/td").Text("some text");
tag.ToString()
.ShouldEqual("<table><tbody><tr><td>some text</td></tr></tbody></table>");
}
示例7: insert_before
public void insert_before()
{
var tag = new HtmlTag("div");
tag.Add("span");
tag.InsertFirst(new HtmlTag("p"));
tag.ToString().ShouldEqual("<div><p></p><span></span></div>");
}
示例8: Transform
public string Transform(Topic current, string data)
{
var props = data.Split(';');
var key = props.First();
try
{
var other = findOther(current, key);
if (other == null) return string.Empty;
return transformFromTopic(current, other, props);
}
catch (ArgumentOutOfRangeException)
{
var tag = new HtmlTag("p").AddClass("bg-warning").Style("padding", "5px");
tag.Add("b").Text($"Unknown topic key '{key}'");
tag.Add("small").Text(" -- CTRL+SHIFT+R to force refresh the topic tree");
return tag.ToString();
}
}
示例9: writeChildNodes
private void writeChildNodes(Topic root, Topic parent, HtmlTag tag, IUrlResolver resolver)
{
parent.Children.Each(childTopic =>
{
var li = tag.Add("li");
li.Add("a").Attr("href", resolver.ToUrl(root, childTopic)).Text(childTopic.Title);
if (childTopic.Children.Any())
{
var ul = li.Add("ul");
writeChildNodes(root, childTopic, ul, resolver);
}
});
}
示例10: nesting_also_supports_jquery_direct_child_syntax
public void nesting_also_supports_jquery_direct_child_syntax()
{
var tag = new HtmlTag("table");
tag.Add("tbody > tr > td").Text("some text");
tag.ToString()
.ShouldEqual("<table><tbody><tr><td>some text</td></tr></tbody></table>");
}
示例11: does_not_return_children_or_siblings_when_treated_as_a_tag_source
public void does_not_return_children_or_siblings_when_treated_as_a_tag_source()
{
var original = new HtmlTag("div");
original.Add("span");
original.After(new HtmlTag("p"));
var tagSource = (ITagSource) original;
var allTags = tagSource.AllTags().ToArray();
allTags.ShouldHaveCount(1);
allTags[0].ShouldBeTheSameAs(original);
}
示例12: I_just_want_to_generate_a_div_with_text_and_a_class
public void I_just_want_to_generate_a_div_with_text_and_a_class()
{
HtmlTag tag = new HtmlTag("div").Text("my text").AddClass("collapsible");
tag.Add("span").Text("inner");
Debug.WriteLine(tag.ToString());
}
示例13: render_html_from_top_if_set_renderfromtop
public void render_html_from_top_if_set_renderfromtop()
{
var tag = new HtmlTag("div");
var child = tag.Add("span").RenderFromTop().Text("hi");
child.ToString().ShouldEqual("<div><span>hi</span></div>");
}
示例14: render_html_from_current_tag_by_default
public void render_html_from_current_tag_by_default()
{
var tag = new HtmlTag("div");
var child = tag.Add("span").Text("hi");
child.ToString().ShouldEqual("<span>hi</span>");
}