Skip to content

Instantly share code, notes, and snippets.

@mitiko
Last active August 9, 2022 14:38
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/3296ed5f3cfeefd90006b6fce88546cf to your computer and use it in GitHub Desktop.
Save mitiko/3296ed5f3cfeefd90006b6fce88546cf to your computer and use it in GitHub Desktop.
Style last 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

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