/// <inheritdoc /> public override async Task ProcessWhileAwareOfModelTypeAsync <TModel>(TagHelperContext context, TagHelperOutput output) { var helper = ViewContext.GetHtmlHelper <TModel>(); var leadingHtml = LeadingHtml?.Invoke(null) ?? LeadingHtmlContent; var heading = Heading != null?Heading.ToHtml() : (HeadingHtml?.Invoke(null) ?? HeadingHtmlContent); if (helper.IsInChameleonFormsSection()) { var s = helper.GetChameleonFormsSection(); using (s.BeginSection(heading: heading, leadingHtml: leadingHtml, context.GetHtmlAttributes())) { var childContent = await output.GetChildContentAsync(); childContent.WriteTo(helper.ViewContext.Writer, HtmlEncoder.Default); } } else { var f = helper.GetChameleonForm(); using (f.BeginSection(heading: heading, leadingHtml: leadingHtml, context.GetHtmlAttributes())) { var childContent = await output.GetChildContentAsync(); childContent.WriteTo(helper.ViewContext.Writer, HtmlEncoder.Default); } } output.SuppressOutput(); }
/// <summary> /// Called when the tag helper is being processed. /// </summary> /// <param name="context">The context within which the tag helper is processed</param> /// <param name="output">The output from the tag helper</param> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var ha = context.GetHtmlAttributes(); FluentConfig?.Invoke(ha); if (!string.IsNullOrWhiteSpace(AddClass)) { ha.AddClass(AddClass); } if (!string.IsNullOrWhiteSpace(Id)) { ha.Id(Id); } if (Disabled.HasValue) { ha.Disabled(Disabled.Value); } ha.Attrs(Attrs); return(Task.CompletedTask); }
/// <inheritdoc /> public override async Task ProcessWhileAwareOfModelTypeAsync <TModel>(TagHelperContext context, TagHelperOutput output) { var helper = ViewContext.GetHtmlHelper <TModel>(); var n = helper.GetChameleonFormsNavigation(); output.TagMode = TagMode.StartTagAndEndTag; output.TagName = null; var childContent = Label?.ToHtml() ?? await output.GetChildContentAsync(HtmlEncoder.Default); if (!string.IsNullOrEmpty(Value) && string.IsNullOrEmpty(Name)) { throw new NotSupportedException($"Form submit specified with Value ({Value}), but not Name."); } ButtonHtmlAttributes buttonOutput; if (!string.IsNullOrEmpty(Value)) { buttonOutput = n.Submit(Name, Value, childContent); } else { buttonOutput = n.Submit(childContent); } FluentAttrs?.Invoke(buttonOutput); var finalOutput = buttonOutput.Attrs(context.GetHtmlAttributes().Attributes); output.Content.SetHtmlContent(finalOutput); }
/// <inheritdoc /> public override async Task ProcessWhileAwareOfModelTypeAsync <TModel>(TagHelperContext context, TagHelperOutput output) { var helper = ViewContext.GetHtmlHelper <TModel>(); var method = Method == FormMethod.Get ? Microsoft.AspNetCore.Mvc.Rendering.FormMethod.Get : Microsoft.AspNetCore.Mvc.Rendering.FormMethod.Post; using (helper.BeginChameleonForm(Action ?? "", method, context.GetHtmlAttributes(), Enctype, OutputAntiforgeryToken)) { var childContent = await output.GetChildContentAsync(); childContent.WriteTo(helper.ViewContext.Writer, HtmlEncoder.Default); } output.SuppressOutput(); }
/// <inheritdoc /> public override async Task ProcessWhileAwareOfModelTypeAsync <TModel>(TagHelperContext context, TagHelperOutput output) { var helper = ViewContext.GetHtmlHelper <TModel>(); var n = helper.GetChameleonFormsNavigation(); output.TagMode = TagMode.StartTagAndEndTag; output.TagName = null; var childContent = Label?.ToHtml() ?? await output.GetChildContentAsync(HtmlEncoder.Default); var buttonOutput = n.Button(childContent); FluentAttrs?.Invoke(buttonOutput); var finalOutput = buttonOutput.Attrs(context.GetHtmlAttributes().Attributes); output.Content.SetHtmlContent(finalOutput); }
/// <summary> /// Called when the tag helper is being processed. /// </summary> /// <param name="context">The context within which the tag helper is processed</param> /// <param name="output">The output from the tag helper</param> public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var attrs = context.GetHtmlAttributes(); if (Size != ButtonSize.Default && Size != ButtonSize.NoneSpecified) { attrs.AddClass($"btn-{Size.Humanize()}"); } if (EmphasisStyle != EmphasisStyle.Default) { attrs.AddClass($"btn-{EmphasisStyle.ToString().ToLower()}"); } if (!string.IsNullOrEmpty(Icon)) { attrs.Attr(TwitterBootstrap3FormTemplate.IconAttrKey, Icon); } return(Task.CompletedTask); }