Example #1
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var items = _breadCrumbManager.BuildMenu(ViewContext);


            var content = await output.GetChildContentAsync();

            output.TagName = "title";
            output.TagMode = TagMode.StartTagAndEndTag;

            var title = _pageTitleBuilder.GenerateTitle(new HtmlString(this.Separator));

            if (!Equals(title, HtmlString.Empty))
            {
                if (!content.IsEmptyOrWhiteSpace)
                {
                    output.PostContent.AppendHtml(new HtmlString(Separator));
                }
                output.PostContent.AppendHtml(title);

                // Add generated page title to context for general access
                ViewContext.HttpContext.Items[typeof(PageTitle)] = new PageTitle()
                {
                    Title = title.ToHtmlString().ToString()
                };
            }
        }
Example #2
0
        public static MvcHtmlString Title(this HtmlHelper html, params string[] titleParts)
        {
            IPageTitleBuilder pageTitleBuilder = DependencyResolver.Current.GetService <IPageTitleBuilder>();

            html.AppendTitleParts(titleParts);

            return(MvcHtmlString.Create(html.Encode(pageTitleBuilder.GenerateTitle())));
        }
Example #3
0
 /// <summary>
 /// Concatenates every title segments using the separator defined in settings.
 /// </summary>
 /// <returns>A string representing the aggregate title for the current page.</returns>
 public static IHtmlContent GenerateTitle(this IPageTitleBuilder builder)
 {
     return(builder.GenerateTitle(null));
 }