-
Notifications
You must be signed in to change notification settings - Fork 7
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
View imports not carried into generated files #18
Comments
I'm porting over some code for RazorSlices, so I might discover a few more issues as I go. This namespace issue becomes more problematic when the template invokes extension methods. Since the namespace isn't imported obviously the extension method won't work as expected, so it too has to be fully qualified and invoked as a static method. So instead of:
It would have to be:
|
I didn't plan to add But if you expected view imports to work and the IDE additionally misleads you, that becomes a problem... Yet I'm not sure I want to introduce this kind of special behavior and implicit dependencies between cshtml files because of this, I'll need to think about it. A primary goal of this library is to remain as simple as possible.
Sure, please report them. 🙂 Also, may I ask why you're porting from RazorSlices (which seems to be designed to be used in ASP.NET) to RazorBlade (which explicitly cannot be used with it) in an ASP.NET app? 😅
Extension methods should work if you add the necessary |
I do have some projects in mind in the future, but I'm just playing around with various options using ASP.NET minimal APIs. I have a tailwind dashboard theme that I'm turning into a sort of reusable component library using RazorBlade, RazorSlices, and Razor components. They all work fine so far, each with strengths and weaknesses. This is mostly straightforward with Razor components and the markup looks nice, but it's complex, heavy and actually has some surprising limitations. Razor Slices and Razor Blade are both good, and look more like classical ASP.NET MVC compared to razor components (at least the way I'm doing it so far), but still very readable and very fast. The structure is simpler so far with RazorBlade because it has a more straightforward synchronous rendering pipeline. I get not wanting to complicate your maintenance load with supporting broader use cases, I'm just putting it out there in case you are interested.
Adding |
Not a huge deal, just a little unexpected. I have a _ViewImports.cshtml that has:
This lets me write this template that without any IDE errors or warnings:
But trying to compile fails:
Basically, all RazorBlade types within a template need to be fully qualified despite the fact that _ViewImports.cshtml imports that namespace. Another case I ran into was a template that returned an HtmlString:
Same problem:
Fully qualifying it as RazorBlade.HtmlString("foo"). Like I said, not a huge deal but unexpected given the standard idioms for razor.
The text was updated successfully, but these errors were encountered: