Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collections template functions #33

Open
15 tasks
technosophos opened this issue Feb 11, 2022 · 0 comments
Open
15 tasks

collections template functions #33

technosophos opened this issue Feb 11, 2022 · 0 comments

Comments

@technosophos
Copy link
Collaborator

Per #25, implement the Sprig functions for Bartholomew. Rather than file an issue for each function, I figured I'd break these down into small batches. (Note: I am not entirely sure all of the functions can be done with the same syntax. I am no pro in writing the Handlebars functions.)

  • list A B C returns a list of [A, B, C]
  • first LIST returns the first item in a list
  • rest LIST returns all but the first in a list
  • last LIST returns the last item in a list
  • initial LIST returns all but the last in a list
  • append ITEM LIST appends an item to end of a list (not sure if this one makes sense to add)
  • prepend ITEM LIST appends an item to start of a list (not sure if this one makes sense to add)
  • concat LIST LIST concatenate two lists into one list
  • reverse LIST reverse the order if items in a list
  • uniq LIST remove duplicates form a list. uniq [1, 1, 1, 2, 2] produces [1, 2]
  • without ITEM LIST removes ITEM from the list
  • has ITEM LIST returns boolean true of the item is in the list
  • compact LIST removes empty items from a list (I think rhai has a definition of empty that we could use here)
  • slice START END LIST extract START-END from a list and return it
  • chunk SIZE LIST chunk a given list into a list of lists, each no larger than SIZE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant