Ghost/core/test/unit
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
..
middleware Remove unnecessary API lookup for activeTheme 2015-09-29 22:54:55 +02:00
server_helpers The {{#get}} helper 2015-10-11 16:51:12 +01:00
api_utils_spec.js Return a single 422 error for invalid values 2015-09-25 10:30:49 +01:00
apps_spec.js Add jscs task to grunt file and clean up files to adhere to jscs rules. 2014-09-17 21:44:29 -04:00
config_spec.js Test support for various URL schemes 2015-09-27 10:31:49 +01:00
error_handling_spec.js Fixup broken error page styles 2015-06-08 12:14:58 +01:00
filters_spec.js Add jscs task to grunt file and clean up files to adhere to jscs rules. 2014-09-17 21:44:29 -04:00
frontend_spec.js Fix failing frontend_spec on windows. Don't rely on path matches. 2015-07-14 11:16:41 +02:00
importer_spec.js Rename error.type to error.errorType 2015-04-22 22:29:45 +02:00
mail_spec.js Fix email sending fail when blog title has a comma 2015-01-09 21:34:24 +00:00
migration_spec.js Maintain tag order for posts 2015-09-02 16:39:34 +01:00
models_pagination_spec.js Add event handling to pagination plugin 2015-06-26 22:56:03 +01:00
permissions_spec.js Add public API permission handling 2015-08-03 19:30:17 +01:00
rss_spec.js RSS Fix: Do not convert protocol relative URLs 2015-07-21 23:16:04 -05:00
server_helpers_index_spec.js Cleans up HTML data attributes on body in default.hbs 2014-11-29 17:09:43 +01:00
server_helpers_template_spec.js refactors the frontend controller 2015-05-05 07:35:08 -05:00
server_spec.js Add jscs task to grunt file and clean up files to adhere to jscs rules. 2014-09-17 21:44:29 -04:00
server_utils_spec.js Fix handling of slugs on import 2015-09-23 17:41:44 +01:00
showdown_client_integrated_spec.js Upgrade grunt-jscs to fix whitespace linting. 2015-04-30 16:14:19 -05:00
sitemap_spec.js Refactor sitemaps to use centralised events 2015-04-05 19:32:18 +01:00
storage_local-file-store_spec.js Use extends correctly & consistently 2015-06-25 19:56:27 +01:00
xmlrpc_spec.js Refactor sitemaps to use centralised events 2015-04-05 19:32:18 +01:00