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

✨ 🎨 Allow foreach else inside of get helper #8160

Merged
merged 1 commit into from
Mar 14, 2017

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Mar 14, 2017

closes #7242

  • before this, the get helper's else was used for empty resultsets
  • the argument was made that we should fall through to a foreach or with helper's else instead
  • I agree that this is the more natural, consistent approach, and so would like to change it for Ghost 1.0

E.g. as of this PR we now have:

{{#get "posts" filter="tag:doesnt-exist"}}
  {{#foreach posts}}
  {{else}}
    this gets executed because there are no results
  {{/foreach}}
{{/get}}

instead of

{{#get "posts" filter="tag:doesnt-exist"}}
  {{#foreach posts}}
  {{else}}
  {{/foreach}}
{{each}}
    this gets executed because there are no results
{{/get}}

closes TryGhost#7242

- before this, the get helper's else was used for empty resultsets
- the argument was made that we should fall through to a foreach or with helper's else instead
- I agree that this is the more natural, consistent approach, and so would like to change it for Ghost 1.0

E.g. as of this PR we now have:

{{#get "posts" filter="tag:doesnt-exist"}}
  {{#foreach posts}}
  {{else}}
    this ges executed because there are no results
  {{/foreach}}
{{/get}}

instead of

{{#get "posts" filter="tag:doesnt-exist"}}
  {{#foreach posts}}
  {{else}}
  {{/foreach}}
{{each}}
    this ges executed because there are no results
{{/get}}
@ErisDS ErisDS added the themes label Mar 14, 2017
@ErisDS ErisDS changed the title ✨ 🎨 All foreach else inside of get helper ✨ 🎨 Allow foreach else inside of get helper Mar 14, 2017
Copy link
Contributor

@kirrg001 kirrg001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works 👍

@kirrg001 kirrg001 merged commit f52e3e7 into TryGhost:master Mar 14, 2017
@ErisDS ErisDS mentioned this pull request Mar 14, 2017
4 tasks
@ErisDS ErisDS deleted the get-helper-changes branch March 18, 2017 12:58
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

Successfully merging this pull request may close these issues.

{{#foreach}}{{else}} fails inside {{#get}} statements with no results
2 participants