Ghost/core/test/unit/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
..
test_tpl Fix @blog globals in special templates 2015-03-28 23:21:10 +02:00
asset_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
author_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
body_class_spec.js Misc helper updates & fixes 2015-05-14 11:42:29 +01:00
content_spec.js Update downsize node module. Small test updates. 2014-11-30 20:49:36 -08:00
date_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
encode_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
excerpt_spec.js Test update to handle downsize improvements 2014-12-14 23:37:00 +00:00
foreach_spec.js Improvements to the {{foreach}} helper 2015-06-29 17:27:57 +01:00
get_spec.js The {{#get}} helper 2015-10-11 16:51:12 +01:00
ghost_foot_spec.js Remove auto-inclusion of jQuery via ghost_foot 2015-09-02 13:39:22 +01:00
ghost_head_spec.js Adds meta referrer tag to the head of ghost pages 2015-07-08 14:59:39 +01:00
has_spec.js Fix has helper tag matching 2015-01-09 21:52:23 +00:00
image_spec.js Change url and image into synchronous helpers 2014-12-29 18:44:15 +00:00
input_password_spec.js rewrites default private.hbs for new zelda styles 2015-05-29 06:25:32 -06:00
is_spec.js Misc helper updates & fixes 2015-05-14 11:42:29 +01:00
meta_description_spec.js Rewrite meta_description and meta_title to depend upon the current context 2015-03-24 22:42:45 +01:00
meta_title_spec.js Misc helper updates & fixes 2015-05-14 11:42:29 +01:00
navigation_spec.js Fix @blog globals in special templates 2015-03-28 23:21:10 +02:00
next_post_spec.js Next/Prev Post helpers include author & tags 2015-08-10 08:58:25 +01:00
page_url_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
pagination_spec.js Fix @blog globals in special templates 2015-03-28 23:21:10 +02:00
plural_spec.js Add replacement for zero in plural helper 2015-09-22 16:00:20 +01:00
post_class_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
prev_post_spec.js Next/Prev Post helpers include author & tags 2015-08-10 08:58:25 +01:00
tags_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
title_spec.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00
url_spec.js Test support for various URL schemes 2015-09-27 10:31:49 +01:00
utils.js Refactor helpers & tests into individual files 2014-10-14 22:52:40 +02:00