-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Possible fix for #1252: Using @partial-block twice in a template not possible #1290
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,13 +249,46 @@ describe('partials', function() { | |
true, | ||
'success'); | ||
}); | ||
it('should be able to render the partial-block twice', function() { | ||
shouldCompileToWithPartials( | ||
'{{#> dude}}success{{/dude}}', | ||
[{}, {}, {dude: '{{> @partial-block }} {{> @partial-block }}'}], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to see a few more test cases. I can think of at least two that we need:
We probably also want to test that inline partials behave as expected when combined with multiple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can add those tests. |
||
true, | ||
'success success'); | ||
}); | ||
it('should render block from partial with context', function() { | ||
shouldCompileToWithPartials( | ||
'{{#> dude}}{{value}}{{/dude}}', | ||
[{context: {value: 'success'}}, {}, {dude: '{{#with context}}{{> @partial-block }}{{/with}}'}], | ||
true, | ||
'success'); | ||
}); | ||
it('should allow the #each-helper to be used along with partial-blocks', function() { | ||
shouldCompileToWithPartials( | ||
'<template>{{#> list value}}value = {{.}}{{/list}}</template>', | ||
[ | ||
{value: ['a', 'b', 'c']}, | ||
{}, | ||
{ | ||
list: '<list>{{#each .}}<item>{{> @partial-block}}</item>{{/each}}</list>' | ||
} | ||
], | ||
true, | ||
'<template><list><item>value = a</item><item>value = b</item><item>value = c</item></list></template>'); | ||
}); | ||
it('should render block from partial with context (twice)', function() { | ||
shouldCompileToWithPartials( | ||
'{{#> dude}}{{value}}{{/dude}}', | ||
[ | ||
{context: {value: 'success'}}, | ||
{}, | ||
{ | ||
dude: '{{#with context}}{{> @partial-block }} {{> @partial-block }}{{/with}}' | ||
} | ||
], | ||
true, | ||
'success success'); | ||
}); | ||
it('should render block from partial with context', function() { | ||
shouldCompileToWithPartials( | ||
'{{#> dude}}{{../context/value}}{{/dude}}', | ||
|
@@ -284,6 +317,50 @@ describe('partials', function() { | |
true, | ||
'<template><outer><nested><outer-block>success</outer-block></nested></outer></template>'); | ||
}); | ||
it('should render nested partial blocks at different nesting levels', function() { | ||
shouldCompileToWithPartials( | ||
'<template>{{#> outer}}{{value}}{{/outer}}</template>', | ||
[ | ||
{value: 'success'}, | ||
{}, | ||
{ | ||
outer: '<outer>{{#> nested}}<outer-block>{{> @partial-block}}</outer-block>{{/nested}}{{> @partial-block}}</outer>', | ||
nested: '<nested>{{> @partial-block}}</nested>' | ||
} | ||
], | ||
true, | ||
'<template><outer><nested><outer-block>success</outer-block></nested>success</outer></template>'); | ||
}); | ||
it('should render nested partial blocks at different nesting levels (twice)', function() { | ||
shouldCompileToWithPartials( | ||
'<template>{{#> outer}}{{value}}{{/outer}}</template>', | ||
[ | ||
{value: 'success'}, | ||
{}, | ||
{ | ||
outer: '<outer>{{#> nested}}<outer-block>{{> @partial-block}} {{> @partial-block}}</outer-block>{{/nested}}{{> @partial-block}}+{{> @partial-block}}</outer>', | ||
nested: '<nested>{{> @partial-block}}</nested>' | ||
} | ||
], | ||
true, | ||
'<template><outer><nested><outer-block>success success</outer-block></nested>success+success</outer></template>'); | ||
}); | ||
it('should render nested partial blocks (twice at each level)', function() { | ||
shouldCompileToWithPartials( | ||
'<template>{{#> outer}}{{value}}{{/outer}}</template>', | ||
[ | ||
{value: 'success'}, | ||
{}, | ||
{ | ||
outer: '<outer>{{#> nested}}<outer-block>{{> @partial-block}} {{> @partial-block}}</outer-block>{{/nested}}</outer>', | ||
nested: '<nested>{{> @partial-block}}{{> @partial-block}}</nested>' | ||
} | ||
], | ||
true, | ||
'<template><outer>' + | ||
'<nested><outer-block>success success</outer-block><outer-block>success success</outer-block></nested>' + | ||
'</outer></template>'); | ||
}); | ||
}); | ||
|
||
describe('inline partials', function() { | ||
|
@@ -332,6 +409,24 @@ describe('partials', function() { | |
true, | ||
'<inner><outer-block>success</outer-block></inner>'); | ||
}); | ||
it('should render nested inline partials with partial-blocks on different nesting levels', function() { | ||
shouldCompileToWithPartials( | ||
'{{#*inline "outer"}}{{#>inner}}<outer-block>{{>@partial-block}}</outer-block>{{/inner}}{{>@partial-block}}{{/inline}}' + | ||
'{{#*inline "inner"}}<inner>{{>@partial-block}}</inner>{{/inline}}' + | ||
'{{#>outer}}{{value}}{{/outer}}', | ||
[{value: 'success'}, {}, {}], | ||
true, | ||
'<inner><outer-block>success</outer-block></inner>success'); | ||
}); | ||
it('should render nested inline partials (twice at each level)', function() { | ||
shouldCompileToWithPartials( | ||
'{{#*inline "outer"}}{{#>inner}}<outer-block>{{>@partial-block}} {{>@partial-block}}</outer-block>{{/inner}}{{/inline}}' + | ||
'{{#*inline "inner"}}<inner>{{>@partial-block}}{{>@partial-block}}</inner>{{/inline}}' + | ||
'{{#>outer}}{{value}}{{/outer}}', | ||
[{value: 'success'}, {}, {}], | ||
true, | ||
'<inner><outer-block>success success</outer-block><outer-block>success success</outer-block></inner>'); | ||
}); | ||
}); | ||
|
||
it('should pass compiler flags', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, previously,
fn === partialBlock
. Are you sure that we don't depend on that elsewhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have searched the
lib
-folder and thesrc
-folder for occurences of the stringpartial-block
in thetmp/issue-1252
-branch and the only matches are in the functionsinvokePartial
andresolvePartial
. Those functions do not check forfn === partialBlock
.But no, I cannot be completely sure. I have just started digging in the internals of Handlebars, there might be something I don't see. I'm pretty confident though. Especially since all tests (including your new ones) are passing.