RazorEngine Render ViewComponent And TagHelpers
Opened this issue · 0 comments
My ultimate goal is to generate output for razor tags
I have a TagHelper With name Ad-Plus.cs
using Microsoft.AspNetCore.Razor.Runtime.TagHelpers;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace DevCore.TagHelpres
{
// You may need to install the Microsoft.AspNetCore.Razor.Runtime package into your project
[HtmlTargetElement("Ad-Plus")]
public class Ad_Plus : TagHelper
{
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = "div";
output.Attributes.SetAttribute("class", "hr-theme-slash");
output.Attributes.SetAttribute("data-toggle", "modal");
output.Attributes.SetAttribute("data-target", "#plusmodels");
output.Content.AppendHtml(" <div class='hr-line'></div>");
output.Content.AppendHtml(" <span class='dx-icon dx-icon-plus'></span>");
output.Content.AppendHtml(" <div class='hr-line'></div>");
}
}
}
Now I want to have a Render html TagHelper in output
@using RazorEngine;
@using RazorEngine.Templating;
@{
string template = "";
var service = RazorEngineService.Create();
service.AddTemplate("template", template);
service.Compile("template");
var result = service.Run("template");
}
@Result
But the output result :