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

Running list of utilities to include in the kit #49

Open
mandicai opened this issue May 12, 2020 · 3 comments
Open

Running list of utilities to include in the kit #49

mandicai opened this issue May 12, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@mandicai
Copy link

mandicai commented May 12, 2020

Desired behavior
To have a filter function that takes an array of words, i.e. ['apples', 'oranges', 'lemons'] and spits out apples, oranges and lemons. If it receives an array of length 2 it will spit out apples and oranges.

Yes I know the solution to this is easy but I always forget how slice works.

Todo
The solution is array.slice(0, -1).join(', ') + ' and ' + array.slice(-1) so just need to add this to a function. Maybe worth adding to journalize?

@mandicai mandicai changed the title Make a utility for taking an array of words and joining them in a copy-edit friendly way Make a utility that takes an array of words and joins them in a copy-edit friendly way May 12, 2020
@mandicai
Copy link
Author

(we already have something like this in the template to process multiple authors:

By {%- for author in context.authors or ['Super Cool Corgi', 'Friends'] -%}
      {% if not loop.last %}{{ authorComma() }}{% elif not loop.first %} and{% endif %} {{ author }}
 {%- endfor -%}

@mandicai mandicai changed the title Make a utility that takes an array of words and joins them in a copy-edit friendly way Running list of utilities to include in the kit Jun 4, 2021
@mandicai
Copy link
Author

mandicai commented Jun 4, 2021

  • Add formatting function for percents, trims extra zero's

@mandicai mandicai added the enhancement New feature or request label Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant