Skip to content

Instantly share code, notes, and snippets.

@ardeay
Last active July 8, 2022 19:49
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/0bb6385617eea7dd89bc3aeab9420dce to your computer and use it in GitHub Desktop.
Save ardeay/0bb6385617eea7dd89bc3aeab9420dce to your computer and use it in GitHub Desktop.
Parsley toJSON Output Example
(** logic to setup param using url query parameters **)
{{$limit = 5}}
{{$page = 0}}
{{if {get_var.page} }}
{{$page = {get_var.page} }}
{{end-if}}
{{if {get_var.limit} }}
{{$limit = {get_var.limit} }}
{{end-if}}
(** code to loop through a content model and make a json ouput **)
[
{{each articles as article limit {$page},{$limit} sort by article.date DESC }}
{{article.toJSON(1, true) }}
{{if {article._length} > {article._num} }}, {{ end-if}}
{{end-each}}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment