Skip to content

Template partial keeps getting html escaped #524

Closed

Description

@BartVanBeurden

I have a layout partial

partials/layout.hbs

<html>
<body>
    <div class="content">
        {{> content}}
    </div>
</body>
</html>

and a message handlebars that uses this layout

message.hbs

{{#> layout}}

    {{#*inline "content"}}
        <b>{{ Data.Message }}</b>
    {{/inline}}

{{/layout}}

With the default configuration all my html tags are getting escaped (both in the layout.hbs as well as in the inline content hbs). Why? How do I fix this?
I don't believe this is normal behaviour for handlebars.js

The only way to render this properly is to pass in NoEscape in the configuration, but this has the unwanted side-effect that my {{ Data.Message }} does not get sanitized and can also contain html.

Activity

  1. oformaniuk commented on Aug 11, 2022

    @oformaniuk
    Member

    Hello @BartVanBeurden
    Looks like a bug to me. Can you please provide a test covering your scenario?

  2. Nisden commented on Dec 22, 2022

    @Nisden
    Contributor

    @zjklee I have created a PR with an unit test demonstrating the issue.

  3. Nisden commented on Dec 22, 2022

    @Nisden
    Contributor

    @zjklee I implemented a fix, but I am not 100% certain its correct, so please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions