本文整理汇总了C#中HtmlTags.HtmlTag.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.ToString方法的具体用法?C# HtmlTag.ToString怎么用?C# HtmlTag.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTags.HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mustache_text
public void mustache_text()
{
var tag = new HtmlTag("span");
tag.MustacheText("prop");
tag.ToString().ShouldEqual("<span>{{prop}}</span>");
}
示例2: AwesomeDisplay
public static string AwesomeDisplay(this IFubuPage page, object model)
{
var type = model.GetType();
var result = new StringBuilder();
var tags = page.Tags(model);
var sl = page.Get<IServiceLocator>();
tags.SetProfile(AwesomeConfiguration.TagProfile);
var tr = new HtmlTag("tr");
foreach (var prop in getProperties(type))
{
var p = new SingleProperty(prop, type);
var elementRequest = new ElementRequest(model, p, sl);
var accessRight = page.Get<IFieldAccessService>().RightsFor(elementRequest);
HtmlTag display = tags.DisplayFor(elementRequest).Authorized(accessRight.Read);
var td = new HtmlTag("td").Append(display);
tr.Append(td);
}
var editLink = new LinkTag("Edit", page.EditUrlFor(model));
tr.Append(new HtmlTag("td").Append(editLink));
var deleteLink = new LinkTag("Delete", page.DeleteUrlFor(model));
tr.Append(new HtmlTag("td").Append(deleteLink));
result.Append(tr.ToString());
return result.ToString();
}
示例3: mustache_attr
public void mustache_attr()
{
var tag = new HtmlTag("a");
tag.MustacheAttr("href", "url");
tag.ToString().ShouldEqual("<a href=\"{{url}}\"></a>");
}
示例4: GetCharisma_Alert
public static string GetCharisma_Alert(Charisma_AlertType type, string title, string msg)
{
var tag = new HtmlTag("div").AddClass("alert").AddClass(type.ToText());
tag.Add("button").AddClass("close").Attr("type", "button").Attr("data-dismiss", "alert").Text("×");
tag.Add("h4").AddClass("alert-heading").Text(title);
tag.Add("p").Text(msg);
return tag.ToString();
}
示例5: SendConfirmationEmail
private void SendConfirmationEmail(User user)
{
var email = new HtmlTag("body")
.Child(new HtmlTag("h3").Text("Thank you for registering"))
.Child(new HtmlTag("div").Id("wrapper")
.Child(new LinkTag("Click here to activate your account",
UrlContext.ToFull(_urlRegistry.UrlFor(new ActivateAccountModel() {Id = user.Id})))));
_emailService.SendEmail(user.Email, _emailSettings.DefaultFromEmailAddress, "Activate your account", email.ToString());
}
示例6: Should_build_tag_modifier
public void Should_build_tag_modifier()
{
var registry = new TestConventionRegistry();
registry.TagModifiers.Count().ShouldEqual(3);
var htmlTag = new HtmlTag("a");
registry.TagModifiers.ToList()[2].Modify(new UIComponentContext(_boolExpr.ToAccessor(), new TestModel(), null), htmlTag);
htmlTag.ToString().ShouldEqual(new HtmlTag("a").AddClass("test").ToString());
}
示例7: 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();
}
示例8: 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();
}
示例9: wrap_body
public void wrap_body()
{
var layout = new DefinitionListLabelAndField();
var display = new TextboxTag().Attr("value", "something");
layout.BodyTag = display;
var wrapper = new HtmlTag("strong");
layout.WrapBody(wrapper);
layout.BodyTag.ShouldBeTheSameAs(display);
wrapper.Children.ShouldHaveTheSameElementsAs(display);
layout.ToString().ShouldContain(wrapper.ToString());
}
示例10: write_to_string
public void write_to_string()
{
var layout = new DefinitionListLabelAndField();
var label = new HtmlTag("span").Text("some text");
layout.LabelTag = label;
var display = new TextboxTag().Attr("value", "something");
layout.BodyTag = display;
var html = layout.ToString();
html.ShouldContain(label.ToString());
html.ShouldContain(display.ToString());
}
示例11: 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();
}
示例12: get_collapsible_partial
// SAMPLE: UsingCollapsibleTag
public CollapsiblePartialViewModel get_collapsible_partial()
{
var inner = new HtmlTag("div");
for (var i = 0; i < 5; i++ )
{
inner.Add("p").Text(Guid.NewGuid().ToString());
}
var tag = new CollapsibleTag("acc1", "This is the collapsible tag");
tag.AppendContent(inner.ToString());
return new CollapsiblePartialViewModel{
Tag = tag
};
}
示例13: 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 '{0}'".ToFormat(key));
tag.Add("small").Text(" -- CTRL+SHIFT+R to force refresh the topic tree");
return tag.ToString();
}
}
示例14: UserStatusesToSpan
public static Nancy.ViewEngines.Razor.IHtmlString UserStatusesToSpan(UserAccountStatuses status)
{
var tag = new HtmlTag("span").AddClass("label");
switch (status)
{
case UserAccountStatuses.ApprovalPending:
tag.Text(UserAccountStatuses.ApprovalPending.ToText());
break;
case UserAccountStatuses.Approved:
tag.AddClass("label-success").Text(UserAccountStatuses.Approved.ToText());
break;
case UserAccountStatuses.Banned:
tag.AddClass("label-important").Text(UserAccountStatuses.Banned.ToText());
break;
case UserAccountStatuses.Disapproved:
tag.AddClass("label-warning").Text(UserAccountStatuses.Disapproved.ToText());
break;
case UserAccountStatuses.NotActive:
tag.AddClass("label-inverse").Text(UserAccountStatuses.NotActive.ToText());
break;
default:
tag.AddClass("label-info").Text("未知");
break;
}
return new NonEncodedHtmlString(tag.ToString());
}
示例15: VisitTableCell
private static void VisitTableCell(HtmlTag cell, ExportRow exportRow)
{
var tag = cell.TagName().ToLower();
if (tag != HtmlTagConstants.Td && tag != HtmlTagConstants.Th )
{
cell.Children.ForEach(c => VisitTableCell(c, exportRow));
return;
}
var isImage = cell.Children.Any(c => c.TagName().ToLower() == HtmlTagConstants.Img);
var text = cell.Children.Any() ? cell.ToString() : cell.Text();
var exportCell = new ExportCell
{
Text = ExportFromTable.HtmlTagRegex.Replace(text ?? string.Empty, string.Empty),
Markup = isImage ? cell.FirstChild().ToString():string.Empty
};
SetColspan(cell, exportCell);
exportRow.AddCell(exportCell);
}