public void testNestedNodesWithList() { HtmlElement td = new HtmlElement("td", "test"); HtmlElement td2 = new HtmlElement("td", "test2"); HtmlElement tr = new HtmlElement("tr", new List<HtmlElement>(){ td, td2 }); Assert.AreEqual("<tr><td>test</td><td>test2</td></tr>", tr.Build()); }
public void testAppendListOfElements() { HtmlElement td = new HtmlElement("td", "test"); HtmlElement td2 = new HtmlElement("td", "test2"); var lst = new List<HtmlElement>() {td, td2}; HtmlElement tr = new HtmlElement("tr"); tr.Append(lst); Assert.AreEqual("<tr><td>test</td><td>test2</td></tr>", tr.Build()); }
public void testNestedNodesWithAppend() { HtmlElement table = new HtmlElement("table"); HtmlElement td = new HtmlElement("td", "test"); HtmlElement td2 = new HtmlElement("td", "test2"); HtmlElement tr = new HtmlElement("tr", new List<HtmlElement>() { td, td2 }); table = table.Append(tr); Assert.AreEqual("<table><tr><td>test</td><td>test2</td></tr></table>", table.Build()); }
public void testAnoymousFunc() { var table = new HtmlElement("table", new Dictionary<string, string>() {{"width", "100%"}}) .Append( ()=> new HtmlElement("tr") .Append(new HtmlElement("td", "test", new Dictionary<string, string>() {{"class", "my-class"}})) .Append(new HtmlElement("td", "test2", new Dictionary<string, string>() {{"class", "my-class"}})) ); Assert.AreEqual("<table width='100%' ><tr><td class='my-class' >test</td><td class='my-class' >test2</td></tr></table>", table.Build()); }
public void testAttributes() { var attrs = new Dictionary<String, String>() { {"class", "my-class and-another"}, {"ng-value", "blah"} }; HtmlElement td = new HtmlElement("td", attrs); Assert.AreEqual("<td class='my-class and-another' ng-value='blah' ></td>", td.Build()); }
private HtmlElement FormatParticipantEventTable(IEnumerable<Event> events) { var tableAttrs = new Dictionary<string, string>() { {"width", "100%"}, {"border", "1"}, {"cellspacing", "0"}, {"cellpadding", "5"} }; var cellAttrs = new Dictionary<string, string>() { {"align", "center"} }; var rows = events.Select(e => new HtmlElement("tr") .Append(new HtmlElement("td", cellAttrs, e.EventTitle)) .Append(new HtmlElement("td", cellAttrs, e.EventLocation)) .Append(new HtmlElement("td", cellAttrs, e.EventStartDate.ToString("g")))).ToList(); var headerLabels = new List<string> {"Event", "Location", "Date"}; var headers = new HtmlElement("tr", headerLabels.Select(el => new HtmlElement("th", el)).ToList()); return new HtmlElement("table", tableAttrs) .Append(headers) .Append(rows); }
private Dictionary<string, object> SetConfirmationMergeData(int parentEventId, IEnumerable<int> kids) { var parentEvent = _eventService.GetEvent(parentEventId); var kidList = kids.Select(kid => _contactService.GetContactByParticipantId(kid)).Select(contact => contact.First_Name + " " + contact.Last_Name).ToList(); var html = new HtmlElement("ul"); var elements = kidList.Select(kid => new HtmlElement("li", kid)); foreach (var htmlElement in elements) { html.Append(htmlElement); } var mergeData = new Dictionary<string, object> { {"EventTitle", parentEvent.EventTitle}, {"EventStartDate", parentEvent.EventStartDate.ToString("g")}, {"ChildNames", html.Build()} }; return mergeData; }
public void testTextNode() { HtmlElement td = new HtmlElement("td", "test"); Assert.AreEqual(td.Build(), "<td>test</td>"); }
public void testBasicHtmlElement() { HtmlElement table = new HtmlElement("table"); Assert.AreEqual(table.Build(), "<table></table>"); }
private void SendRsvpMessage(List<RegisterEventObj> saved, string token) { var evnt = _eventService.GetEvent(saved.First().EventId); var childcareRequested = saved.Any(s => s.ChildcareRequested); var loggedIn = _contactService.GetMyProfile(token); var childcareHref = new HtmlElement("a", new Dictionary<string, string>() { { "href", string.Format("https://{0}/childcare/{1}", _configurationWrapper.GetConfigValue("BaseUrl"), evnt.EventId) } }, "this link").Build(); var childcare = _contentBlockService["eventRsvpChildcare"].Content.Replace("[url]", childcareHref); var mergeData = new Dictionary<string, object> { {"Event_Name", evnt.EventTitle}, {"HTML_Table", SetupTable(saved, evnt).Build()}, {"Childcare", (childcareRequested) ? childcare : ""} }; var defaultContact = _contactService.GetContactById(AppSetting("DefaultContactEmailId")); var comm = _communicationService.GetTemplateAsCommunication( AppSetting("OneTimeEventRsvpTemplate"), defaultContact.Contact_ID, defaultContact.Email_Address, evnt.PrimaryContact.ContactId, evnt.PrimaryContact.EmailAddress, loggedIn.Contact_ID, loggedIn.Email_Address, mergeData ); _communicationService.SendMessage(comm); }
private String ChildcareData(IList<Participant> children) { var el = new HtmlElement("span", new Dictionary<string, string>(), "You have indicated that you need childcare for the following children:") .Append(new HtmlElement("ul").Append(children.Select(child => new HtmlElement("li", child.DisplayName)).ToList())); return el.Build(); }
/// <summary> /// Append an element to this one /// </summary> /// <param name="el">The element to append</param> /// <returns>An HtmlElement after appending the requested Element</returns> public HtmlElement Append(HtmlElement el) { this.childrenElements.Add(el); return this; }