This is the updated code of the backend controller
[IsBackOffice]
public class EmailTemplateEditorBackendController : UmbracoAuthorizedApiController
{
[System.Web.Http.HttpGet]
public HttpResponseMessage GetTemplate(string id)
{
IPublishedContent model = Umbraco.TypedContent(id);
var tt = model.GetPropertyValue<string>("htmlText");
var response = new HttpResponseMessage();
response.Content = new StringContent(tt);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return response;
}
}
Is it possible to render html code in the Umbraco backend?
Hello everyone,
I was trying to render Html code in the Umbraco Backend, but I can't
I created a new property editor containing a simple div and I wanted to get some html code from a backend controller and render it.
The purpose, in the future, is to save an email template in a textbox and having a preview inside the property editor.
This is the code of the manifest file:
This is the code of editor.html
This is the code of editor.controller.js
This is the code of the backend controller
This is the final result the html code is not rendered properly
Hi Enrico,
Maybe you can change this line in your view :
You had 2 bind directives in there
Dave
Hi Dave,
thanks for your suggestion. But the result remains the same. The Html does not render properly.
Maybe you should output the result of the API call to the console to see if there are no issues with it.
Because i'm actually doing the same in a property editor and that works just fine :
https://bitbucket.org/dawoe/embed-property-editor/src/1720f8b0e81b0723241f25f4def3e7451ad244bd/Sources/Dawoe.OEmbedPickerPropertyEditor/Views/editor.html?at=master&fileviewer=file-view-default#editor.html-4
Dave
I will try to output the Api result to the Chrome Extension Postman and see what happens.
Thanks for your help
I will let you know
I tried to return a test string from the Api controller
This is the code of the controller
This is the result:
As you can see the HTML is rendered with inside two double quotes.
I read some topic around and I tried to use $sce to render the code, but is not possible in the Umbraco back end.
Hello Enrico
Can you try changing the
to
Hello Kasper,
thanks for your help.
I tried your solution, but I get a null result using IHtmlString.
Hello guys,
did anyone of you used $sce with Umbraco Backend to escape html code?
I just discovered that outside Umbraco backend it works.
I created a basic html page using the same libraries used in the backend
This is the code :
And it renders the html code without any problems.
Why is not not doing the same in Umbraco backend?
I found the solution.
I hope this could be useful.
This is the updated code of the backend controller
is working on a reply...