ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
753 stars 113 forks source link

Programmatic rendering of tag helpers #156

Open tafs7 opened 3 years ago

tafs7 commented 3 years ago

Is there any way to programmatically render the tag helpers (e.g. from a custom base RazorPage<T> type with the final bundle name and version appended?

I am porting some code that used to rely on this from old school MVC and the System.Web.Optimization inside a method on a custom base WebViewPage<T>:

string result = "";
result += System.Web.Optimization.Styles.Render("~/bundles/mycss").ToString();

 //several other conditional appends here...

return MvcHtmlString.Create(result);

And it does this several times with different bundles that it appends together based on some ViewBag booleans.

This is used by several views, all inheriting from this custom base type.

Not sure how to work around this or if there's a better approach to this.

nvirth commented 2 years ago

@tafs7 could you solve it since? I'm in the same boat...

tafs7 commented 2 years ago

Sorry, @nvirth . I moved on to other projects since then. I think just ended up designing a new approach and refactoring the code a bunch, but don't recall the details and no longer have access to that codebase.