Skip to content

Instantly share code, notes, and snippets.

@midnai
Created February 11, 2018 00:13
Show Gist options
  • Save midnai/a5c93ae6a15d006441e3a2a520dfdc7f to your computer and use it in GitHub Desktop.
Save midnai/a5c93ae6a15d006441e3a2a520dfdc7f to your computer and use it in GitHub Desktop.
Get a resume from a big text in twig
{% for d in data %}
{% set text = d.resumen |split(' ') %}
{% set t2 = '' %}
{% if text|length > 10 %}
{% for t in text|slice(0, 10) %}
{% set t2 = t2 ~ ' ' ~ t %}
{% endfor %}
{% set t2 = t2 ~ '...' %}
{% else %}
{% set t2 = text|join(' ') %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment