本文整理汇总了C#中HtmlTag.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.ToString方法的具体用法?C# HtmlTag.ToString怎么用?C# HtmlTag.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: is_visible_set_to_true_by_default
public void is_visible_set_to_true_by_default()
{
var tag = new HtmlTag("div");
tag.Visible().ShouldBeTrue();
tag.ToString().ShouldEqual("<div></div>");
}
示例2: append_all_tags_from_a_sequence
public void append_all_tags_from_a_sequence()
{
var sequence = new[] { new HtmlTag("br"), new HtmlTag("hr") };
var parent = new HtmlTag("div");
parent.Append(sequence);
parent.ToString().ShouldEqual("<div><br></br><hr /></div>");
}
示例3: 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>");
}
示例4: do_not_write_closing_tag
public void do_not_write_closing_tag()
{
var tag = new HtmlTag("span").Id("id");
tag.NoClosingTag();
tag.ToString().ShouldEqual("<span id=\"id\">");
}
示例5: create_and_return_a_link_as_a_child_of_another_tag
public void create_and_return_a_link_as_a_child_of_another_tag()
{
var tag = new HtmlTag("div");
var link = tag.ActionLink("click", "important", "invoke");
link.ToString().ShouldEqual("<a href=\"#\" class=\"important invoke\">click</a>");
tag.ToString().ShouldEqual("<div><a href=\"#\" class=\"important invoke\">click</a></div>");
}
示例6: 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>");
}
示例7: append_adds_a_new_child_and_return_the_original
public void append_adds_a_new_child_and_return_the_original()
{
var parent = new HtmlTag("div");
var resultOfAppend = parent.Append("p");
resultOfAppend.ShouldBeTheSameAs(parent);
parent.ToString().ShouldEqual("<div><p></p></div>");
}
示例8: 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>");
}
示例9: 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>");
}
示例10: is_authorized_value_false_makes_tag_hidden_regardless_of_visibility
public void is_authorized_value_false_makes_tag_hidden_regardless_of_visibility()
{
var tag = new HtmlTag("div").Authorized(false);
tag.ToString().ShouldBeEmpty();
tag.Visible(true).ToString().ShouldBeEmpty();
tag.Visible(false).ToString().ShouldBeEmpty();
}
示例11: can_opt_out_of_html_encoded_inner_text
public void can_opt_out_of_html_encoded_inner_text()
{
var tag = new HtmlTag("div");
tag.Text("<b>Hi</b>");
tag.Encoded(false);
tag.ToString().ShouldEqual("<div><b>Hi</b></div>");
}
示例12: X
public void X()
{
var wrapper = new HtmlTag("div");
var tag = new HtmlTag("input").NoClosingTag();
wrapper.Append(tag);
wrapper.ToString()
.ShouldEqual("<div><input /></div>");
// actually renders "<div><input />")
}
示例13: Transform
public string Transform(Topic current, string data)
{
var parts = data.Split(';');
var url = _urls.ToUrl(current, parts.First());
var image = new HtmlTag("img").Attr("src", url).Style("max-width", "100%");
if (parts.Length == 0)
{
return image.ToString();
}
var header = new HtmlTag("h5", x =>
{
x.Add("strong").Text(parts.Last());
});
return header.ToString() + image.ToString();
}
示例14: 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();
}
示例15: GenerateHtml
public string GenerateHtml(Topic topic)
{
var html = _generator.Generate(topic);
var builder = new StringBuilder(html);
topic.Substitutions.Each((key, value) => { builder.Replace(key, value); });
var script = _webSocketScript.Replace("%WEB_SOCKET_ADDRESS%", _settings.WebsocketAddress);
builder.Replace("</head>", script + "\n</head>");
var tag = new HtmlTag("script").Attr("language", "javascript").Attr("src", "/topics.js");
builder.Replace("</head>", tag.ToString() + "\n</head>");
return builder.ToString();
}