-
-
Notifications
You must be signed in to change notification settings - Fork 369
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 make TSynMustache.Render emit unescaped html or Partials #221
Comments
I've come up with a work around (rather than a solution) I subclassed the TMVCMustacheViewEngine class and changed the Execute function to look for a value set in the ViewModel.
My controller class can add this using this code
or
Maybe the View Engines could allow this property to be exposed directly ? |
Closed because there is a work around, would be useful to add to the tutorials though. |
Thank you for the workaround. We'll use your findings to make a built-in solution. |
1 similar comment
Thank you for the workaround. We'll use your findings to make a built-in solution. |
Hmmm, my work around blew up tonight, in the Duck Typing part of PrepareModels. My "new" work around is like this
and the setting of this value, given a variable on the controller
|
Also noticed that Partials are not working, here is the unit I have written to get Escaped html and Mustache Partials working.
|
You changes about partials have been merged. However to avoid escaping in a mustache template you can just use 3 curly braces to open a tag instead of 2. I mean |
The various Render methods on the TSynMustache class contain an EscapeInvert parameter to turn off html escaping.
However this is not used by the default TMVCMustacheViewEngine class, so all html is escaped
e.g. "
" becomes "<br>" and so is thus rendered as "
" in the browser rather than as a line break.
I have not yet come up with a fix, as the TMVCMustacheViewEngine descends from TMVCBaseViewEngine and there does not appear to be an easy way to add the extra "EScapeInvert" param to the Execute method.
And as the TMVCController.GetRenderedView method that calls the Execute method, also creates the instance of the ViewEngine via the ViewEngineClass type, the constructor cannot be altered to add an "EscapeInvert" parameter.
Am I missing something ?
The text was updated successfully, but these errors were encountered: