Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Blake Clerke 103 posts 346 karma points
    18 days ago
    Blake Clerke
    0

    Umbraco 8 Textarea Macro Parameter Not Rendering HTML Markup

    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: @Html.Raw(Model.MacroParameters["embed"])

    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!

  • Shaishav Karnani from digitallymedia.com 280 posts 1268 karma points
    18 days ago
    Shaishav Karnani from digitallymedia.com
    0

    Hi Blake,

    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.

    Regards,

    Shaishav

  • Blake Clerke 103 posts 346 karma points
    18 days ago
    Blake Clerke
    0

    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!

  • Steve Megson 48 posts 320 karma points c-trib
    18 days ago
    Steve Megson
    0

    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.

  • Shaishav Karnani from digitallymedia.com 280 posts 1268 karma points
    18 days ago
    Shaishav Karnani from digitallymedia.com
    0

    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. Model.Value("bodyText")

    Cheers,

    Shaishav

  • Blake Clerke 103 posts 346 karma points
    18 days ago
    Blake Clerke
    0

    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!

  • Gopakumar R 2 posts 93 karma points c-trib
    1 week ago
    Gopakumar R
    100

    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.

    @Html.Raw(System.Web.HttpUtility.HtmlDecode(Convert.ToString(Model.MacroParameters["embed"])))
    

    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.

Please Sign in or register to post replies

Write your reply to:

Draft