Skip to content
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

Pass partials in partials #1360

Closed
MaxLeiter opened this issue Jul 6, 2017 · 8 comments
Closed

Pass partials in partials #1360

MaxLeiter opened this issue Jul 6, 2017 · 8 comments

Comments

@MaxLeiter
Copy link

Kind of a unique case, but I imagine there's a way to accomplish what I want. I'm currently localizing my program with i18next, and have a template like so:

{{> ../user_name nick=from}}
{{translate 'client.invited.invited'}}
{{#if invitedYou}}
	{{translate 'client.invited.you'}}
{{else}}
	{{> ../user_name nick=invited}}
{{/if}}
{{translate 'client.invited.to'}}
{{{parse channel}}}

In English, the above is perfect. However in other languages, the order may be different.

Thus, something like {{translate 'invited' user={{> ../user_name nick=from}} channel={{parse channel}}}} would be ideal, where I could use options.hash.user to fetch the rendered template.

Is there a way to accomplish this?

@MaxLeiter MaxLeiter changed the title Pass multiple subexpressions into expression Pass partials in partials Jul 6, 2017
@nknapp
Copy link
Collaborator

nknapp commented Jul 7, 2017

With helpers, you can write {{translate channel=(parse channel)}}. But I don't think that works with partials.

I would probably try to write a custom block helper for something of this complexity.

@MaxLeiter
Copy link
Author

parse channel worked, but you're correct, the user_name partial did not

@xPaw
Copy link

xPaw commented Jul 7, 2017

@nknapp what about supporting partials in subexpressions? Like {{translate channel=(> my_partial channel)}}

@nknapp
Copy link
Collaborator

nknapp commented Jul 9, 2017

@xPaw You could create a new issue for that. This one was more a question.
@MaxLeiter one other thing that you could use are partial-blocks.
http://handlebarsjs.com/partials.html

Edit: replace link to blog post by link to official documentation

@nknapp
Copy link
Collaborator

nknapp commented Jul 9, 2017

@xPaw but new features are currently on hold, until we have a spec for the handlebars languages

@MaxLeiter
Copy link
Author

@nknapp how long until the spec is complete? where can I follow the progress?

@nknapp
Copy link
Collaborator

nknapp commented Aug 2, 2017

see #1277

@nknapp
Copy link
Collaborator

nknapp commented Apr 5, 2020

Closing due to inactivity

@nknapp nknapp closed this as completed Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants