Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RazorEngine Render ViewComponent And TagHelpers #582

Open
shahabksh opened this issue Aug 24, 2021 · 0 comments
Open

RazorEngine Render ViewComponent And TagHelpers #582

shahabksh opened this issue Aug 24, 2021 · 0 comments

Comments

@shahabksh
Copy link

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 :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant