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

[WIP] {{#get}} helper + filter parameter #5608

Closed
wants to merge 2 commits into from

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Jul 28, 2015

This PR is a very rough WIP, featuring 2 individual pieces of work:

Each piece will eventually be split into 3 complete PRs with full tests. This PR is here so that people can start to see and play with the functionality being added.

If you pull down this PR (tip: this blog post explains how http://dev.ghost.org/easy-git-pr-test/)

You'll be able to start playing with the get helper in your themes.

Evolving documentation exists on the get helper issue: #4439 but the basics are as follows:

  • {{#get}}{{/get}} is a block helper, so it has opening and closing tags and supports else.
  • the first thing you pass to it should be the type of resource you want to get: posts, tags or users and they need to be enclosed in double quotes
  • you can then pass options such as include, limit or filter to modify the query
  • filter is described in depth in API: Filter parameter (GQL filter queries spec) #5604
  • once you've done your get you can loop over the resources you've fetched using foreach

Here's an example:

{{#get "posts" limit="5" filter="featured:true"}}
    <ol>
        {{#foreach posts}}
            <li><a href="{{url}}"><span class="number" aria-hidden="true">{{@number}}</span>{{title}}</a></li>
        {{/foreach}}
    </ol>
{{/get}}

The main things which are not working yet (off the top of my head) are advanced joins from users and tags, filtering based on dates, pages behaviour needs to be fixed by #5151 and please also note that there is no order parameter yet #5602.

Have fun and leave lots of feedback please!

@ErisDS
Copy link
Member Author

ErisDS commented Oct 11, 2015

Going to close this PR for now, in favour of #5619, as that PR adds the {{#get}} helper.

The filter parameter (#5604) will be finalised separately, including ensuring all the joins & permissions work as needed (#5614, #5615) and then I'll reopen this updating the get helper to ensure it works as needed.

@ErisDS ErisDS closed this Oct 11, 2015
@ErisDS ErisDS deleted the get-helper branch November 1, 2015 09:00
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.

1 participant