Last active
July 8, 2022 19:49
-
-
Save ardeay/0bb6385617eea7dd89bc3aeab9420dce to your computer and use it in GitHub Desktop.
Parsley toJSON Output Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** 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