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

[Feature request] support to use blazor razor as template engine to render report and save the raw string #30717

Closed
congzhangzh opened this issue Mar 6, 2021 · 5 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-prerendering Issues related to prerendering blazor components
Milestone

Comments

@congzhangzh
Copy link

Is your feature request related to a problem? Please describe.

Hope blazor razor can be use as a template render tools to render report, I use C# interpolate string、 JavaScript interpolate string、 Python Jinja2 to generator report before.

But razor for blazor is more powerful, as all the template language just support express embedded and with some type of directives to do control flow, which is very limit and a free form like Blazor/PHP/JSP is more welcome.

So, if razor flor blazor can be use standalone or with minimum env setup, it will be a great to to do report generation tools development like.

razor component(RazorRenderComponent)

<table>
@for(var case in doc.Select('/testcase')
{
   <tr> <td>@case.Attribute["Name"]</td> <td>@case.Attribute["passed"]</td></tr>
}
</table>
@code{

public    XDocument doc;
}

main program

int Main(string[] args)
{
var render=new RazorRenderComponent()
render.doc=XDocument.Load('junit.xml')
var result=render.render();
System.Console.WriteLine(result);
}

Describe the solution you'd like

Please consider provider a simple api to render result to string, and minimum the context init process, like DI

Additional context

Blazor's free form render process is really cool, support statement and no need special and limited directives to do flow control, it will make report generator funcation easy to develop or release as an standalone program.

@congzhangzh
Copy link
Author

@shanselman how do you think about this idea?

BTW, blazor syntax is really easy than some type of react syntax, free form of for loop is better than some type of map in react.

@mkArtakMSFT mkArtakMSFT added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Mar 7, 2021
@congzhangzh
Copy link
Author

@mkArtakMSFT BTW, razor & blazor use the same template engine?

@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Mar 8, 2021
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Mar 8, 2021
@ghost
Copy link

ghost commented Mar 8, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@javiercn javiercn added the feature-prerendering Issues related to prerendering blazor components label Apr 20, 2021
@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@mkArtakMSFT
Copy link
Member

mkArtakMSFT commented Dec 3, 2023

This is addressed by: #46935
You can find a sample code for how to use the new API for a templating engine scenario in our preview release announcement blog post: https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-3/ (look for Render Razor components outside of ASP.NET Core section)

@guardrex I checked the docs and it seems that the writeup you added for that PR didn't actually include the templating engine scenario. I think it should as this comes up quite often. Can you please expand that writeup to cover the templating engine scenario.

@guardrex
Copy link
Contributor

guardrex commented Dec 3, 2023

@mkArtakMSFT ... I don't think that's the right spot. Can you see if it's completely covered here? ...

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-components-outside-of-aspnetcore?view=aspnetcore-8.0

@ghost ghost locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-prerendering Issues related to prerendering blazor components
Projects
None yet
Development

No branches or pull requests

4 participants