erknrio
7/22/2016 - 10:39 AM

Twig is integer. FROM: http://stackoverflow.com/questions/36895116/twig-how-to-check-if-variable-is-a-number-integer#answer-36895117

{#
Usamos una expresion regular buscando digitos.
Si encuentra uno o mas (\d) es un numero.

Para optimizar la regexp podemos usar https://regex101.com/
#}
{% if myvar matches '/[0-9]+/' %}
  {{ "Es entero" }}
{% else %}
  {{ "No es entero" }}
{% endif %}