Skip to content

Inline partials "leak" from block context to global context #523

@dudabone

Description

@dudabone

Hi,

First of all, I must say - great project!

To my question - could it be that the way that Handlebars.java treats inline partials that are defined from within a certain block is inconsistent with the behavior of handlebars.js? If I got it right, the inline partials should "live" only in the scope of the block from which they are defined. Seems like this is not the case in Handlebars.java. Consider the following template:

main.hbs:

main has partials:<br>
-------------<br>
{{>inherit1}}
-------------<br>
{{>inherit2}}

with the following partials:

base.hbs:

text from base partial<br>
{{#> inlinePartial}}{{/inlinePartial}}<br>

inherit1.hbs:

inherit1<br>
{{#>base}}
{{#*inline "inlinePartial"}}
    inline partial defined by inherit1, called from base
{{/inline}}
{{/base}}

inherit2.hbs:

inherit2<br>
{{#>base}}
{{/base}}

The expected result, as rendered in handlebars.js is:

main has partials:

-------------
inherit1
text from base partial
inline partial defined by inherit1, called from base
-------------
inherit2
text from base partial

Whereas in Handlebars.java the result is:

main has partials:
-------------
inherit1
text from base partial
inline partial defined by inherit1, called from base
-------------
inherit2
text from base partial
inline partial defined by inherit1, called from base

As you can see, the line "inline partial defined by inherit1, called from base" has "leaked" from inherit1.hbs to inherit2.hbs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions