-
Notifications
You must be signed in to change notification settings - Fork 260
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
Cannot use HtmlHelper from view #22
Comments
RazorLight has no HtmlHelpers support. So for Raw encoding use our own iimplementation of this
|
Yes, this works 👍 but it is a bit ugly since VS returns an error and red squiggly line. Anyway to tell VS that this is correct? a using statement?
|
Visual studio tries to use built-in Razor tooling, that's why it shows you errors, as it knows nothing about RazorLight |
I understand :) but are you aware of anyway i can supress this error message for this exact line to ensure others does not get confused because of this error? That will require an extension to VS? |
I will add html helpers support in the future, so you won't see this annoying errors, but for now - you should deal with it) |
It's been 2.5 years, still no html.raw capability. What is needed to add this? |
I feel many issues in RazorLight repo have been closed while they actually shouldn't have been. |
I moved on to just using regular razor, it was not very difficult. Using it in my MIT licensed mail sender project. https://github.com/DigitalRuby/MailDemon/blob/master/Services/RazorRenderer.cs |
Thanks. I've made a quick mail sender component as well for my company. Now this is already done using RazorLight we will stick with it for the moment but for sure I won't choose RazorLight ever again in the future |
FWIW, this is a real problem on .NET core. Visual Studio will always try to compile .cshtml files (even using the nuget package to disable this), and @Raw doesn't compile using normal razor syntax. The only way I could do it was use @Html.Raw in cshtml files, then load the files manually into strings, replacing @Html.Raw with @Raw. It's a shame @Html.Raw could not have been implemented, all the rest are nice to haves but this is a real issue which involves pretty horrible hacks to work. |
@jmevel I was unaware of this feature request since helping Ivan, since the original requestor closed it. Its a hard problem to deal with when people are frustrated about things out of my hands (not aware of pain point). And then, rather than opening a new issue, people post on the Closed issue expecting people will see it. As far as making this work, I don't see why it would be impossible. |
@jzabroski people comment on closed issues because they can still be re-opened. If you want tickets to be re-created then fine I'll do that for another one which was closed by Ivan but in my opinion this action wasn't justified. |
@jzabroski Actually even after re-reading the comments I wouldn't be able to open a new ticket and simply explain the problem. I haven't used RazorLight for a while. But you should definitely read what I wrote some time ago on this ticket. |
@jmevel I'm sorry for your paint points - I don't use string templates, but it does seem like that is the one area users complain most about. Recent PRs from others have sought to address some holes, and it has overall improved the code base a bit. I get why people comment on old issues, but I think there is some "netiquette" around bumping issues closed >3 years ago. |
Using
@Html.Raw("<span>test</span>")
returns a TemplateCompilationException.With internal error message "The name 'Html' does not exist in the current context".
I assume you need to setup the HtmlHelper() for it to work?
Any other way i can pass inn a Html string from a model?
The text was updated successfully, but these errors were encountered: