Skip to content

Instantly share code, notes, and snippets.

@mitiko
Created August 9, 2022 14:33
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 mitiko/30f65dd6198c594f5467c3c0d9ae4043 to your computer and use it in GitHub Desktop.
Save mitiko/30f65dd6198c594f5467c3c0d9ae4043 to your computer and use it in GitHub Desktop.
Style first word with a Tera macro
{% macro style_first_word(string) %}
{% set words = string | split(pat=" ") %}
{% set first_word = words | first %}
{% set remaining_words = words | slice(start=1) | join(sep=" ") %}
<span class="first-word">
{{ first_word }}
</span>
{{ remaining_words }}
{% endmacro style_first_word %}
@mitiko
Copy link
Author

mitiko commented Aug 9, 2022

Ended up not liking how this looks and made a last word version as well.

@mitiko
Copy link
Author

mitiko commented Aug 9, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment