-
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
Partial parameters #410
Comments
I see where your train of thought is going. My understanding of partials leads me to believe that the partials take their data from the parent context that called them, but I could be wrong. But simple conditionals remove the need to do all that craziness.
var page1 = {
title : "User Profile",
isLeft : false,
isRight : false,
user : {
name : "Pierce Moore",
friends : [
{ name : "Nancy", age : 28 },
{ name : "Bobby", age : 25 }
]
}
};
var page2 = {
title : "Administrator",
isLeft : true,
isRight : true,
user : {
name : "Pierce Moore",
friends : [
{ name : "Nancy", age : 28 },
{ name : "Bobby", age : 25 }
]
}
};
$(function() {
var tpl = Handlebars.compile( templateSelector );
$("#page1").html(tpl(page1));
$("#page2").html(tpl(page2));
});
{{#if isLeft}}
<!-- Left side content -->
{{/if}}
{{#if user}}
<p>Name: {{user.name}}</p>
<p>Friends</p>
<ul>
{{#each user.friends}}
<li>Name: {{name}}, age: {{age}}</li>
{{/each}}
</ul>
{{/if}}
{{#if isRight}}
<!-- Right side content -->
{{/if}} |
This is going to have the same resolution as #182. My plan is to add support for this syntax |
kpdecker when will {{> foo bar=bat}} be released? need that feature bad! |
This will land in 2.0. I hope that there will be a prerelease of 2.0 in the On Mon, Jan 27, 2014 at 1:58 PM, Jordan [email protected] wrote:
|
I'm not sure if your illustration
Is this possible? Or would there be a way to merge the two objects to make a single context? |
Using a helper worked for this. #182 (comment) |
@nathagey you need to be on the 2.x codeline for the native support. That's in alpha right now and not available on all channels. |
I'm trying to pass parameter from partials and based on that value i wan to do some condition check. This is sample implementation i'm trying to do.
Header Template, header.html
First Approach Is this possible?
Page1 Template, page1.html
Second Approach This worked fine for me
Please let me know if first approach is possible and which one is better.
The text was updated successfully, but these errors were encountered: