Ghost/core/server/helpers
Hannah Wolfe 3e40637cd4 The {{#get}} helper
closes #4439

- adds basic get helper which works with the current API
- allows theme developers to make requests against the API
- supports block params and @error message
- includes 100% test coverage using posts

----

The `{{#get}}` helper is an asynchronous block helper which allows for making
requests for data from the API. This allows theme developers to customise the
data which can be shown on a particular page of a blog.

Requests can be made to the posts, tags or users API endpoints:

```
{{#get "posts" limit="3"}}
  {{#foreach posts}}
     <a href="{{url}}">{{title}}</a>
  {{/foreach}}
{{/get}}
```

The `{{#get}}` helper must be used as a block helper, it supports `{{else}}`
logic, for when no data matching the request is available or if an error has
occurred:

```
{{#get "posts" tag="photo"}}
  ...
{{else}}
  {{#if @error}}
    <p>Something went wrong: {{@error}}</p>
  {{else}}
    <p>No posts found</p>
  {{/if}}
{{/get}}
```

The helper also supports block params, meaning the data it outputs can be
given a different name:

```
{{#get "posts" featured="true" as |featured|}}
  {{#foreach featured}}
    ...
  {{/foreach}}
{{/get}}
```

Please Note: At present asynchronous helpers cannot be nested.
2015-10-11 16:51:12 +01:00
..
tpl Navigation helper amends 2015-02-15 21:44:10 +00:00
asset.js Serve files to core/built/assets/ 2015-03-12 15:59:02 -06:00
author.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
body_class.js Misc helper updates & fixes 2015-05-14 11:42:29 +01:00
content.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
date.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
encode.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
excerpt.js Update excerpt helper to properly filter HTML footnotes 2015-01-01 06:45:06 +01:00
foreach.js Improvements to the {{foreach}} helper 2015-06-29 17:27:57 +01:00
get.js The {{#get}} helper 2015-10-11 16:51:12 +01:00
ghost_foot.js Remove auto-inclusion of jQuery via ghost_foot 2015-09-02 13:39:22 +01:00
ghost_head.js Adds meta referrer tag to the head of ghost pages 2015-07-08 14:59:39 +01:00
has.js Fix has helper tag matching 2015-01-09 21:52:23 +00:00
image.js Change url and image into synchronous helpers 2014-12-29 18:44:15 +00:00
index.js The {{#get}} helper 2015-10-11 16:51:12 +01:00
input_password.js rewrites default private.hbs for new zelda styles 2015-05-29 06:25:32 -06:00
is.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
meta_description.js Fix meta description for static pages 2015-05-20 13:05:33 +10:00
meta_title.js Misc helper updates & fixes 2015-05-14 11:42:29 +01:00
navigation.js Fix @blog globals in special templates 2015-03-28 23:21:10 +02:00
page_url.js Refactoring hard-coded frontend route keywords 2015-03-23 15:00:02 +00:00
pagination.js Fix @blog globals in special templates 2015-03-28 23:21:10 +02:00
plural.js Add replacement for zero in plural helper 2015-09-22 16:00:20 +01:00
post_class.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
prev_next.js Next/Prev Post helpers include author & tags 2015-08-10 08:58:25 +01:00
tags.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
template.js refactors the frontend controller 2015-05-05 07:35:08 -05:00
title.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
url.js Update urlFor to handle 'nav' contexts 2015-01-31 09:29:53 -08:00
utils.js Theming updates for password protection 2015-05-13 19:48:24 +01:00