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

Support inline partials #7444

Closed
bep opened this issue Jul 1, 2020 · 3 comments · Fixed by #7445
Closed

Support inline partials #7444

bep opened this issue Jul 1, 2020 · 3 comments · Fixed by #7445
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Jul 1, 2020

This is currently not possible:

{{ $v := partial "foo" . }}

{{ define "partials/foo" }}
Partial
{{ end }}

You can use the template syntax, but that does not support assigning the result to a variable ...

@bep bep added the Enhancement label Jul 1, 2020
@bep bep added this to the v0.74 milestone Jul 1, 2020
@bep bep self-assigned this Jul 1, 2020
bep added a commit to bep/hugo that referenced this issue Jul 1, 2020
@pamubay
Copy link

pamubay commented Jul 1, 2020

Amazing!! 🎊

i use define and template a lot.
The inability to assign the result into variable,
in some cases it forces me to write a partial file even though the code is quite small. 😞

Thanks for your work. 🥳

bep added a commit to bep/hugo that referenced this issue Jul 1, 2020
@bep
Copy link
Member Author

bep commented Jul 1, 2020

Yes, I think this will be a welcomed addition for many. This will also work:

Value: {{ partial "my-inline-partial" . }}

{{ define "partials/my-inline-partial" }}
{{ $value := 32 }}
{{ return $value }}
{{ end }}

/cc @regisphilibert

bep added a commit to bep/hugo that referenced this issue Jul 1, 2020
bep added a commit to bep/hugo that referenced this issue Jul 1, 2020
@bep bep closed this as completed in #7445 Jul 1, 2020
bep added a commit that referenced this issue Jul 1, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants