Я ломаю голову, почему не выбран TagHelper вверх.
Код: Выделить всё
namespace NemoPdfNet.TagHelpers
{
public class LogoTagHelper : TagHelper
{
public required string Brand { get; set; }
public required Dictionary Logos { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (!string.IsNullOrEmpty(Brand) && Brand == "whitelabel")
output.SuppressOutput();
else
{
output.TagName = "img";
if (!Logos.ContainsKey(Brand))
{
output.Attributes.SetAttribute("src", Logos["default"]);
output.Attributes.SetAttribute("class", "pdf-header-logo default");
}
else
{
output.Attributes.SetAttribute("src", Logos[Brand]);
output.Attributes.SetAttribute("class", "pdf-header-logo " + Brand);
}
}
}
}
}
Код: Выделить всё
@using NemoPdfNet
@using NemoPdfNet.Models
@using NemoPdfNet.Requests
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, NemoPdfNet.TagHelpers
Код: Выделить всё
@if (!string.IsNullOrEmpty(Model.Brand))
{
model="new NemoPdfNet.Models.LogoViewModel { Brand = Model.Brand, Logos = Model.Logos }" />
}
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/784 ... g-rendered