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
base: master
from

Conversation

Projects
None yet
1 participant
@ErisDS
Member

ErisDS commented Jul 28, 2015

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

  • an initial implementation of the {{#get}} helper, refs #4439
  • adding the filter parameter to the API, refs #5604 - main body of the work is in TryGhost/GQL#2

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 #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 added some commits Jun 27, 2015

Get helper
closes #4439

- adds get helper + tests

@ErisDS ErisDS referenced this pull request Sep 18, 2015

Closed

Query (get) helper #4439

@ErisDS

This comment has been minimized.

Show comment
Hide comment
@ErisDS

ErisDS Oct 11, 2015

Member

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.

Member

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 ErisDS:get-helper branch Nov 1, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment