public HtmlDocument() { RootTag = new HtmlTag("html"); DocType = "<!DOCTYPE html>"; Head = RootTag.Add("head"); _title = Head.Add("title"); Body = RootTag.Add("body"); Last = Body; }
public static MvcHtmlString SaveButton(this HtmlHelper htmlHelper, string cssclass) { var button = new HtmlTag("input").Add("type", "submit"); button.Add("name", "SaveButton"); button.Add("value", " Save "); button.Add("class", "btn btn-default svySaveButton" + ((cssclass != null) ? " " + cssclass : "")); return(button.ToHtmlString()); }
public static MvcHtmlString SaveAndRefreshButton(this HtmlHelper htmlHelper) { var button = new HtmlTag("input").Add("type", "submit"); button.Add("name", "SaveAndRefreshButton"); button.Add("value", "Save & Refresh"); button.Add("class", "btn btn-default svySaveButton svySaveAndRefreshButton"); return(button.ToHtmlString()); }
public static MvcHtmlString SaveButton(this HtmlHelper htmlHelper, string Caption = " Save ", string ButtonNameAttribute = "SaveButton", string cssclass = null) { var button = new HtmlTag("input").Add("type", "submit"); button.Add("name", ButtonNameAttribute); button.Add("value", Caption); button.Add("class", "btn btn-default svySaveButton" + ((cssclass != null) ? " " + cssclass : "")); //button.Add("onclick", "$('form#form').submit();this.disabled=true"); return(button.ToHtmlString()); }
public static HtmlTag JoinTagAtEnd(this HtmlTag tag, string tagName) { if (!tag.Children.Any()) { return(tag.Add(tagName)); } HtmlTag lastTag = tag.Children.Last(); return(lastTag.TagName() == tagName ? lastTag : tag.Add(tagName)); }
public static T JoinTagAtEnd <T>(this HtmlTag tag) where T : HtmlTag, new() { if (!tag.Children.Any()) { return(tag.Add <T>()); } HtmlTag lastTag = tag.Children.Last(); return((T)(lastTag is T ? lastTag : tag.Add <T>())); }
public string ToHtml() { var div = new HtmlTag("div"); foreach (var log in Logs) { div.Add("pre").Text(log); div.Add("hr"); } return(div.ToString()); }
public HtmlTag get_scheduled_jobs() { var tag = new HtmlTag("div"); tag.Add("h1").Text("Scheduled Jobs Monitor"); tag.Add("p").Text("at {0} -- reload the page to refresh the data".ToFormat(DateTime.Now)); var schedule = _persistence.FindAll(_graph.Name); tag.Append(new ScheduledJobTable(_urls, schedule)); return(tag); }
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(); }
public OutlineNodeTag(string label, string anchor = null) : base("li") { _container = Add("div").AddClass("node-container"); if (anchor.IsEmpty()) { _container.Add("span").Text(label); } else { _container.Add("a").Attr("href", "#" + anchor).Text(label); } }
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()); }
private HtmlTag buildTopNode() { HtmlTag tag = new HtmlTag("table").Attr("cellPadding", "0").Attr("cellSpacing", "0").AddClass(GrammarConstants.GRAMMAR_SELECTOR).Hide(); HtmlTag headerCell = tag.Add("thead/tr/td").AddClass(GrammarConstants.HEADER_CONTAINER); headerCell.Add("span").Text(_fixture.Policies.AddGrammarText); headerCell.Add("span").AddClass(GrammarConstants.SELECTION_REQUIRED).Text(GrammarConstants.REQUIRED).Render (_fixture.IsSingleSelection()); headerCell.ActionLink(GrammarConstants.CLOSE, GrammarConstants.CLOSER).Render(!_fixture.IsSingleSelection()); return(tag); }
public HtmlTag get_subscriptions() { var div = new HtmlTag("div"); div.Add("h3").Text("Subscription Persistence"); div.Append(new DescriptionBodyTag(Description.For(_persistence))); div.Add("h3").Text("Nodes"); div.Append(new TransportNodeTableTag(_persistence.AllNodes())); div.Add("h3").Text("Subscriptions"); div.Append(new SubscriptionStorageTableTag(_persistence.AllSubscriptions())); return(div); }
public void find_first_child() { var tag = new HtmlTag("a"); tag.Add("span"); tag.Add("span"); var div = tag.Add("div"); tag.Add("input"); tag.Add("button"); new TagHolder(tag).ForChild("div").ShouldBeTheSameAs(div); }
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>"); }
public HtmlTag Build() { HtmlTag tag = buildTopNode(); var body = tag.Add("tbody"); AddTaggingLinkIfAtTopLevel(body); var commentLink = new SelectorLinkTag(GrammarConstants.COMMENT); commentLink.Label(GrammarConstants.COMMENT); body.Add("tr").Append(commentLink.TagName("td")); _fixture.PossibleGrammarsFor(new StepLeaf()).Where(x => !(x is DoGrammarStructure)).Each(grammar => { _link = new SelectorLinkTag(grammar.Name); _link.TagName("td"); body.Add("tr").Append(_link); grammar.AcceptVisitor(this, new Step()); }); return(tag); }
private HtmlTag createBehaviorList(BehaviorChain chain) { var div = new HtmlTag("div").Id("chain-summary"); var level = 0; chain.NonDiagnosticNodes().Each(node => { var description = Description.For(node); var child = div.Add("div").AddClass("node-title"); if (level > 0) { var image = _document.Image("arrow-turn-000-left-icon.png"); image.Style("padding-left", (level * 5) + "px"); child.Append(image); } child.Add("span").Text(description.Title); level++; }); return(div); }
public HtmlDocument Index() { var tags = new List <HtmlTag>(); var groups = _graph .Actions() .Where(x => x.HandlerType.HasAttribute <FubuDiagnosticsAttribute>() && (!x.HasInput || x.HandlerType.GetAttribute <FubuDiagnosticsAttribute>().ShownInIndex) && x.Method.Name != "Index") .GroupBy(x => x.HandlerType.GetAttribute <FubuDiagnosticsAttribute>().Description) .OrderBy(x => x.Key); groups.Each(group => { tags.Add(new HtmlTag("h3").Text(group.Key)); var ul = new HtmlTag("ul"); tags.Add(ul); group.Each <ActionCall>(action => { string text = action.Method.Name; action.Method.ForAttribute <FubuDiagnosticsAttribute>(att => text = att.Description); ul.Add("li/a").Text(text) .Attr("href", action.ParentChain().RoutePattern); }); }); return(BuildDocument("Home", tags.ToArray())); }
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>"); }
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>"); }
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); }
public HtmlTag Finish() { var anchor = new HtmlTag("a") .AddClass("btn") .Attr("href", _actionUrl); if (!string.IsNullOrEmpty(_id)) { anchor.Id(_id); } if (_additionalCssClasses.Count > 0) { anchor.AddClasses(_additionalCssClasses); } if (_iconClasses != null) { anchor.Add("i").AddClasses(_iconClasses); anchor.AppendHtml(string.Format(" {0}", _buttonText)); } else { anchor.AppendHtml(_buttonText); } return(anchor); }
public HtmlTag BuildFolderTag(SpecificationFolder folder) { var folderTag = new HtmlTag("li"); var link = linkTagForFolder(folder); folderTag.Add("span").AddClass("folder").Append(link); var ul = folderTag.Add("ul"); var builder = new ChildTagBuilder(this, ul); folder.ImmediateChildren.Each(x => x.AcceptVisitor(builder)); return(folderTag); }
public HtmlTag get_tasks() { var peers = _repository.FindPeers(); var cache = new Cache <Uri, TransportNode>(); peers.Each(peer => peer.OwnedTasks.Each(x => cache[x] = peer)); var tag = new HtmlTag("div"); tag.Add("h1").Text("Task Assignements"); var table = new TableTag(); tag.Append(table); table.AddClass("table"); table.AddHeaderRow(row => { row.Header("Task"); row.Header("Assigned to"); row.Header("Control Channel"); }); var tasks = _tasks.PermanentTasks().Union(_tasks.ActiveTasks()).ToArray(); tasks.Each(uri => { table.AddBodyRow(row => addRow(row, uri, cache)); }); return(tag); }
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>"); }
public static HtmlTag Activities(this HtmlHelper htmlHelper, ActivitiesResult result) { if (result.Activities.Any()) { var date = DateTime.MinValue; var now = DateTime.UtcNow.ToGmtStandardTime(); var lastActivity = result.Activities.Last(); var ol = new HtmlTag("ol").AddClass("timeline").AddClass("timeline--complete"); var urlHelper = htmlHelper.GetUrlHelper(); var activitiesUrl = urlHelper.Activities(result.Total); foreach (var activity in result.Activities) { var at = activity.At.ToGmtStandardTime(); var activityUrl = urlHelper.Activity(activity); var activityText = htmlHelper.Activity(activity); ol.Add("li", li => li.AddClasses(activity.At.Date != date ? "first" : "", activity == lastActivity ? "last" : "") .Append("h4", h4 => h4.Title(at.ToString("U")).Text(at.ToRelativeFormat(now))) .Append("p", p => p.AddClass("activity").Text(activityText)) .Append("p", p => { p.AddClass("meta").AppendText("At").AppendHtml(" ") .Append("time", time => time.Text(at.ToString("h:mm tt"))).AppendHtml(" "); if (!string.IsNullOrEmpty(activityUrl)) { p.Add("a", a => a.Attr("href", activityUrl).Text("See details")); } }) ); date = activity.At.Date; } if (result.Activities.Count() != result.Total) { ol.Add("li", li => li.AddClass("all-activity") .Add("p", p => p.AddClass("activity")) .Add("a", a => a.Attr("href", activitiesUrl).Text("See all activity"))); } return(ol); } return(new HtmlTag("p").Text("You have no recent activity")); }
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>"); }
public void add_and_return_a_child_tag_by_type() { var original = new HtmlTag("div"); var child = original.Add <HiddenTag>(); child.ToString().ShouldBe("<input type=\"hidden\">"); original.ToString().ShouldBe("<div><input type=\"hidden\"></div>"); }
public void add_returns_the_newly_created_child_tag() { var original = new HtmlTag("div"); var child = original.Add("span"); child.ToString().ShouldBe("<span></span>"); original.ToString().ShouldBe("<div><span></span></div>"); }
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>"); }
public static HtmlTag Span(this HtmlTag tag, string text, params string[] classes) { HtmlTag span = tag.Add("span").Text(text); classes.Each(x => span.AddSafeClassName(x)); return(tag); }
private void AddTaggingLinkIfAtTopLevel(HtmlTag body) { if (!_fixture.IsAFixture()) { var tagsLink = new SelectorLinkTag(GrammarConstants.TAGS); tagsLink.Label(GrammarConstants.TAGS_LABEL); body.Add("tr").Append(tagsLink.TagName("td")); } }
public void nesting_also_supports_jquery_direct_child_syntax() { var tag = new HtmlTag("table"); tag.Add("tbody > tr > td").Text("some text"); tag.ToString() .ShouldBe("<table><tbody><tr><td>some text</td></tr></tbody></table>"); }
public void add_multiple_levels_of_nesting() { var tag = new HtmlTag("table"); tag.Add("tbody/tr/td").Text("some text"); tag.ToString() .ShouldBe("<table><tbody><tr><td>some text</td></tr></tbody></table>"); }
private static HtmlTag createExample(HtmlTag htmlTag, string methodCall) { var example = new HtmlTag("fieldset").AddClass("tag"); example.Add("legend").Text(methodCall); example.Append(new HtmlTag("code").AddClass("source").Text(htmlTag.ToString())); example.Append(new HtmlTag("div").AddClass("rendered").Append(htmlTag)); return(example); }
public HtmlTag VisualizePartial(BehaviorFinish finish) { var description = Description.For(finish.Correlation.Node); var tag = new HtmlTag("div").AddClass("behavior-finish"); tag.Add("span").Text("Finished ").Add("i").Text(description.Title); if (!finish.Succeeded) { tag.Next = new ExceptionReportTag(finish.Exception); tag.Add("span").Text(finish.Exception.ExceptionType).AddClass("exception"); } tag.PrependGlyph("icon-chevron-up"); return(tag); }
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(); } }
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); } }); }
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>"); }
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); }
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()); }