Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am using a macro to embed a hubspot form code into a parameter that is a textarea called embed.
The macro itself just renders the embed code in the parameter like so:
The output of this is literally printing the html markup that I put into the macro parameter.
If I output just the parameter without Html.Raw then I get the decoded markup printed out. ( & instead of "&")
I've done this in previous versions of Umbraco just fine but it seems that I can no longer do this in v8. Am I missing something? Is there a way to solve this? For now I am just going to put the direct code I need into the macro but I lose the flexibility of letting editors add their own various hubspot forms on other pages. Any ideas how I could output the code from the parameter as actual HTML markup? Thank you!
This works on RTE but when we actually render it on the template then I can replicate your issue on v8.1.3
So, it's a bug that needs to be reported to HQ.
Oh, thank you. I didn't realize it was a bug. I was using the macro in the grid editor to insert the macro. I didn't try this macro directly in the RTE though.
Are you saying you were able to see the issue when you were inserting the macro in the RTE?
I just want to make sure I understand what you tried before submitting a bug to explain it. Thank you for checking it out!
All the macro parameter values are stored HTML-encoded, since they may be inside the HTML content of the RTE. Version 8 is missing a HTML decoding step, so the values you get from Model.MacroParameters are still encoded.
I think it's just been missed when the macro rendering code was rewritten - in version 7 the decoding step was pretty well hidden in old code.
It worked fine when i viewed in the RTE in back-office.
But when we rendered on the template (as below) then it was literally printing the html markup.
I submitted a bug on github for this.
I tested trying to render the macro through the RTE and the macro actually disappears after I save the page (it is marked as use in RTE but not render in RTE - I don't need to see the code rendered in the backoffice).
Also, thank you both for responding and checking this out!
Updating the workaround here in case others are looking for similar issue.
The macro parameter value is stored encoded and hence when you use the @Html.Raw(..) it renders the html mark up. As a workaround i tried performing a decode before passing it onto the Raw function and i was able to render the HTML form. Below is the code i used.
PS:This is a workaround until the issue is fixed by HQ.
I couldn't manage to get the backoffice showing the form render but the webpage shows it right.
I am also having an issue with outputting Macro HTML in Umbraco 8. Certain tags in my Macro view work fine (divs, a tags etc), but buttons and inputs are stripped out.
Will not render in the back office, but does on the final output. Anybody any thoughts?
Update: I found the answer to my problem of missing html markup, tags and attributes in macros rendered in the back office for Umbraco 8. Turns out to be the introduction of an new 'sanitizing' class. There are several whitelist variables in this class that strip out your html content. Read the solution here:- https://www.stephengarside.co.uk/blog/webdev/umbraco-8-removing-html-tags-and-attributes-from-macros-in-back-office/
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted