/// <summary> /// Outputs a field with passed in HTML. /// </summary> /// <param name="labelHtml">The HTML for the label part of the field</param> /// <param name="elementHtml">The HTML for the field element part of the field</param> /// <param name="validationHtml">The HTML for the validation markup part of the field</param> /// <param name="metadata">Any field metadata</param> /// <param name="isValid">Whether or not the field is valid</param> /// <returns>A field configuration that can be used to output the field as well as configure it fluently</returns> public IFieldConfiguration Field(Nancy.ViewEngines.Razor.IHtmlString labelHtml, Nancy.ViewEngines.Razor.IHtmlString elementHtml, Nancy.ViewEngines.Razor.IHtmlString validationHtml = null, ModelMetadata metadata = null, bool isValid = true) { var fc = new FieldConfiguration(); fc.SetField(() => Form.Template.Field(labelHtml, elementHtml, validationHtml, metadata, new ReadonlyFieldConfiguration(fc), isValid)); return(fc); }
/// <summary> /// Creates the HTML for a submit <button>. /// </summary> /// <param name="content">The content to display for the button</param> /// <param name="type">The type of submit button; submit (default) or reset</param> /// <param name="value">The value to submit with the button</param> /// <param name="id">The id/name to use for the button</param> /// <param name="htmlAttributes">Any HTML attributes that should be applied to the button</param> /// <returns>The HTML for the submit button</returns> public static Nancy.ViewEngines.Razor.IHtmlString BuildButton(Nancy.ViewEngines.Razor.IHtmlString content, string type = null, string id = null, string value = null, HtmlAttributes htmlAttributes = null) { var t = new TagBuilder("button") { InnerHtml = content.ToHtmlString() }; if (value != null) { t.Attributes.Add("value", value); } if (type != null) { t.Attributes.Add("type", type); } if (id != null) { t.Attributes.Add("id", id); t.Attributes.Add("name", id); } if (htmlAttributes != null) { t.MergeAttributes(htmlAttributes.Attributes, true); } return(new NonEncodedHtmlString(t.ToString(TagRenderMode.Normal))); }
/// <summary> /// Creates a form section /// </summary> /// <param name="form">The form the message is being created in</param> /// <param name="title">The title for the section</param> /// <param name="nested">Whether the section is nested within another section</param> /// <param name="leadingHtml">Any HTML to output at the start of the section</param> /// <param name="htmlAttributes">Any HTML attributes to apply to the section container</param> public Section(IForm <TModel, TTemplate> form, Nancy.ViewEngines.Razor.IHtmlString title, bool nested, Nancy.ViewEngines.Razor.IHtmlString leadingHtml = null, HtmlAttributes htmlAttributes = null) : base(form, false) { _title = title; _nested = nested; _leadingHtml = leadingHtml; _htmlAttributes = htmlAttributes; Initialise(); }
public static Nancy.ViewEngines.Razor.HelperResult BeginSection(Nancy.ViewEngines.Razor.IHtmlString title, Nancy.ViewEngines.Razor.IHtmlString leadingHtml, HtmlAttributes htmlAttributes) { #line default #line hidden return(new Nancy.ViewEngines.Razor.HelperResult(__razor_helper_writer => { #line 15 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden WriteLiteralTo(__razor_helper_writer, " <fieldset"); #line 16 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, htmlAttributes); #line default #line hidden WriteLiteralTo(__razor_helper_writer, ">\r\n"); WriteLiteralTo(__razor_helper_writer, " <legend>"); #line 17 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, title); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "</legend>\r\n"); WriteLiteralTo(__razor_helper_writer, " "); #line 18 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, leadingHtml); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n"); WriteLiteralTo(__razor_helper_writer, " <dl>\r\n"); #line 20 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden })); #line 20 "..\..\Templates\HtmlHelpers.cshtml" }
public static Nancy.ViewEngines.Razor.HelperResult BeginNestedSection(Nancy.ViewEngines.Razor.IHtmlString title, Nancy.ViewEngines.Razor.IHtmlString leadingHtml, HtmlAttributes htmlAttributes) { #line default #line hidden return(new Nancy.ViewEngines.Razor.HelperResult(__razor_helper_writer => { #line 23 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden WriteLiteralTo(__razor_helper_writer, " <dt>"); #line 24 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, title); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "</dt>\r\n"); WriteLiteralTo(__razor_helper_writer, " <dd>\r\n"); WriteLiteralTo(__razor_helper_writer, " "); #line 26 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, leadingHtml); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n"); WriteLiteralTo(__razor_helper_writer, " <dl"); #line 27 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, htmlAttributes); #line default #line hidden WriteLiteralTo(__razor_helper_writer, ">\r\n"); #line 28 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden })); #line 28 "..\..\Templates\HtmlHelpers.cshtml" }
/// <summary> /// Creates the HTML for a label. /// </summary> /// <param name="for">The name/id for the checkbox</param> /// <param name="labelText">The text inside the label</param> /// <param name="htmlAttributes">Any HTML attributes that should be applied to the checkbox</param> /// <returns>The HTML for the checkbox</returns> public static Nancy.ViewEngines.Razor.IHtmlString BuildLabel(string @for, Nancy.ViewEngines.Razor.IHtmlString labelText, HtmlAttributes htmlAttributes) { var t = new TagBuilder("label"); t.Attributes.Add("for", TagBuilder.CreateSanitizedId(@for)); t.InnerHtml = labelText.ToHtmlString(); if (htmlAttributes != null) { t.MergeAttributes(htmlAttributes.Attributes, false); } return(new NonEncodedHtmlString(t.ToString(TagRenderMode.Normal))); }
public static Nancy.ViewEngines.Razor.HelperResult BeginField(Nancy.ViewEngines.Razor.IHtmlString labelHtml, Nancy.ViewEngines.Razor.IHtmlString elementHtml, Nancy.ViewEngines.Razor.IHtmlString validationHtml, ModelMetadata fieldMetadata, IReadonlyFieldConfiguration fieldConfiguration) { #line default #line hidden return(new Nancy.ViewEngines.Razor.HelperResult(__razor_helper_writer => { #line 68 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden #line 69 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, BeginFieldInternal(labelHtml, elementHtml, validationHtml, fieldConfiguration, fieldMetadata)); #line default #line hidden #line 69 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden WriteLiteralTo(__razor_helper_writer, " <dl>\r\n"); #line 71 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden })); #line 71 "..\..\Templates\HtmlHelpers.cshtml" }
public static Nancy.ViewEngines.Razor.HelperResult MessageParagraph(Nancy.ViewEngines.Razor.IHtmlString paragraph) { #line default #line hidden return(new Nancy.ViewEngines.Razor.HelperResult(__razor_helper_writer => { #line 97 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden WriteLiteralTo(__razor_helper_writer, " <p>\r\n"); WriteLiteralTo(__razor_helper_writer, " "); #line 99 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, paragraph); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n"); WriteLiteralTo(__razor_helper_writer, " </p>\r\n"); #line 101 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden })); #line 101 "..\..\Templates\HtmlHelpers.cshtml" }
public IFieldConfiguration Label(string labelText) { LabelText = new NonEncodedHtmlString(HttpUtility.HtmlEncode(labelText)); return this; }
public void SetField(Nancy.ViewEngines.Razor.IHtmlString field) { _field = () => field; }
public static Nancy.ViewEngines.Razor.HelperResult BeginFieldInternal(Nancy.ViewEngines.Razor.IHtmlString labelHtml, Nancy.ViewEngines.Razor.IHtmlString elementHtml, Nancy.ViewEngines.Razor.IHtmlString validationHtml, IReadonlyFieldConfiguration fieldConfiguration, ModelMetadata fieldMetadata) { #line default #line hidden return(new Nancy.ViewEngines.Razor.HelperResult(__razor_helper_writer => { #line 56 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden WriteLiteralTo(__razor_helper_writer, " <dt>"); #line 57 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, labelHtml); #line default #line hidden #line 57 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, new HtmlString(fieldMetadata != null && fieldMetadata.IsRequired ? " <em class=\"required\">*</em>" : "")); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "</dt>\r\n"); WriteLiteralTo(__razor_helper_writer, " <dd>\r\n"); WriteLiteralTo(__razor_helper_writer, " "); #line 59 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, GetPrependedHtml(fieldConfiguration)); #line default #line hidden #line 59 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, elementHtml); #line default #line hidden #line 59 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, GetAppendedHtml(fieldConfiguration)); #line default #line hidden #line 59 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, GetHint(fieldConfiguration)); #line default #line hidden WriteLiteralTo(__razor_helper_writer, " "); #line 59 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, validationHtml); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\r\n"); #line 60 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden })); #line 60 "..\..\Templates\HtmlHelpers.cshtml" }
public IFieldConfiguration WithHint(Nancy.ViewEngines.Razor.IHtmlString hint) { Hint = hint; return(this); }
/// <summary> /// Creates a top-level form section. /// </summary> /// <example> /// @using (var s = f.BeginSection("Section title")) { /// @s.FieldFor(m => m.FirstName) /// } /// </example> /// <typeparam name="TModel">The view model type for the current view</typeparam> /// <typeparam name="TTemplate">The type of HTML template renderer the form is using</typeparam> /// <param name="form">The form the section is being created in</param> /// <param name="title">The title for the section</param> /// <param name="leadingHtml">Any HTML to output at the start of the section</param> /// <param name="htmlAttributes">Any HTML attributes to apply to the section container specified as an anonymous object</param> /// <returns>The form section</returns> public static Section <TModel, TTemplate> BeginSection <TModel, TTemplate>(this IForm <TModel, TTemplate> form, string title, Nancy.ViewEngines.Razor.IHtmlString leadingHtml = null, object htmlAttributes = null) where TTemplate : IFormTemplate { return(form.BeginSection(title, leadingHtml, htmlAttributes.ToHtmlAttributes())); }
/// <summary> /// Creates a nested form section. /// </summary> /// <example> /// @using (var s = f.BeginSection("Section title")) { /// using (var ss = s.BeginSection("Nested section title")) { /// @ss.FieldFor(m => m.FirstName) /// } /// } /// </example> /// <typeparam name="TModel">The view model type for the current view</typeparam> /// <typeparam name="TTemplate">The type of HTML template renderer the form is using</typeparam> /// <param name="section">The section the section is being created under</param> /// <param name="title">The title for the section</param> /// <param name="leadingHtml">Any HTML to output at the start of the section</param> /// <param name="htmlAttributes">Any HTML attributes to apply to the section container</param> /// <returns>The nested form section</returns> public static Section <TModel, TTemplate> BeginSection <TModel, TTemplate>(this Section <TModel, TTemplate> section, string title, Nancy.ViewEngines.Razor.IHtmlString leadingHtml = null, HtmlAttributes htmlAttributes = null) where TTemplate : IFormTemplate { return(new Section <TModel, TTemplate>(section.Form, new NonEncodedHtmlString(HttpUtility.HtmlEncode(title)), true, leadingHtml, htmlAttributes)); }
public IFieldConfiguration Append(Nancy.ViewEngines.Razor.IHtmlString html) { _appendedHtml.Add(html); return(this); }
/// <summary> /// Creates a message. /// </summary> /// <param name="form">The form the message is being created in</param> /// <param name="messageType">The type of message to display</param> /// <param name="heading">The heading for the message</param> public Message(IForm <TModel, TTemplate> form, MessageType messageType, Nancy.ViewEngines.Razor.IHtmlString heading) : base(form, false) { _messageType = messageType; _heading = heading; Initialise(); }
/// <summary> /// Creates the HTML for a paragraph in the message. /// </summary> /// <param name="paragraph">The paragraph to output</param> /// <returns>The HTML for the paragraph</returns> public virtual Nancy.ViewEngines.Razor.IHtmlString Paragraph(Nancy.ViewEngines.Razor.IHtmlString paragraph) { return(Form.Template.MessageParagraph(paragraph)); }
public IFieldConfiguration OverrideFieldHtml(Nancy.ViewEngines.Razor.IHtmlString html) { _fieldHtml = html; return(this); }
public IFieldConfiguration Label(Nancy.ViewEngines.Razor.IHtmlString labelHtml) { LabelText = labelHtml; return(this); }
public static Nancy.ViewEngines.Razor.HelperResult BeginMessage(MessageType messageType, Nancy.ViewEngines.Razor.IHtmlString heading) { #line default #line hidden return(new Nancy.ViewEngines.Razor.HelperResult(__razor_helper_writer => { #line 86 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden WriteLiteralTo(__razor_helper_writer, " <div class=\""); #line 87 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, string.Format("{0}{1}", messageType.ToString().ToLower(), "_message")); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "\">\r\n"); WriteLiteralTo(__razor_helper_writer, " <h3>"); #line 88 "..\..\Templates\HtmlHelpers.cshtml" WriteTo(__razor_helper_writer, heading); #line default #line hidden WriteLiteralTo(__razor_helper_writer, "</h3>\r\n"); WriteLiteralTo(__razor_helper_writer, " <div class=\"message\">\r\n"); #line 90 "..\..\Templates\HtmlHelpers.cshtml" #line default #line hidden })); #line 90 "..\..\Templates\HtmlHelpers.cshtml" }
public virtual Nancy.ViewEngines.Razor.IHtmlString BeginNestedSection(Nancy.ViewEngines.Razor.IHtmlString title, Nancy.ViewEngines.Razor.IHtmlString leadingHtml, HtmlAttributes htmlAttributes) { return(HtmlHelpers.BeginNestedSection(title, leadingHtml, htmlAttributes)); }
public virtual Nancy.ViewEngines.Razor.IHtmlString BeginField(Nancy.ViewEngines.Razor.IHtmlString labelHtml, Nancy.ViewEngines.Razor.IHtmlString elementHtml, Nancy.ViewEngines.Razor.IHtmlString validationHtml, ModelMetadata fieldMetadata, IReadonlyFieldConfiguration fieldConfiguration, bool isValid) { return(HtmlHelpers.BeginField(labelHtml, elementHtml, validationHtml, fieldMetadata, fieldConfiguration)); }
public virtual Nancy.ViewEngines.Razor.IHtmlString MessageParagraph(Nancy.ViewEngines.Razor.IHtmlString paragraph) { return(HtmlHelpers.MessageParagraph(paragraph)); }
public virtual Nancy.ViewEngines.Razor.IHtmlString BeginMessage(MessageType messageType, Nancy.ViewEngines.Razor.IHtmlString heading) { return(HtmlHelpers.BeginMessage(messageType, heading)); }
public IFieldConfiguration Label(Nancy.ViewEngines.Razor.IHtmlString labelHtml) { LabelText = labelHtml; return this; }
public IFieldConfiguration OverrideFieldHtml(Nancy.ViewEngines.Razor.IHtmlString html) { _fieldHtml = html; return this; }
public virtual void Write(Nancy.ViewEngines.Razor.IHtmlString htmlString) { HtmlHelper.ViewContext.Writer.Write(htmlString); }
public IFieldConfiguration Label(string labelText) { LabelText = new NonEncodedHtmlString(HttpUtility.HtmlEncode(labelText)); return(this); }