Skip to content

Instantly share code, notes, and snippets.

@ardeay
Created March 2, 2017 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ardeay/cdcfed6dd2c1ddb672ded64b2478ece5 to your computer and use it in GitHub Desktop.
Save ardeay/cdcfed6dd2c1ddb672ded64b2478ece5 to your computer and use it in GitHub Desktop.
Custom Zesty.io JSON API endpoint
{
"data": [
{{if {get_var.start} }} {{ $start = {get_var.start} }} {{else}} {{$start = 0}} {{end-if}}
{{if {get_var.limit} }} {{ $limit = {get_var.limit} }} {{else}} {{$limit = 100}} {{end-if}}
{{each blog_article as art limit {$start},{$limit} }}
{
"zid" : {{art.zid}},
"name" : "{{art.title}}",
"body" : "{{art.article_body.escapeForJs()}}",
"tags" : [
{{each blog_tag as tag where find_in_set(tag.zid,'{art.tags}') }}
{
"zid" : {{tag.zid}},
"name" : "{{tag.name}}"
}
(** echo a the comma unless it is the last item **)
{{if {tag._length} != {tag._num} }},{{end-if}}
{{end-each}}
]
}
(** echo a the comma unless it is the last item **)
{{if {art._length} != {art._num} }},{{end-if}}
{{end-each}}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment