Skip to content

Instantly share code, notes, and snippets.

@cole007
Created December 4, 2018 17:26
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 cole007/b0a0fee593bdaf16fd14b3b134effb7e to your computer and use it in GitHub Desktop.
Save cole007/b0a0fee593bdaf16fd14b3b134effb7e to your computer and use it in GitHub Desktop.
{% macro revealSecret(startId, elements) %}
{% set outputInt = startId %}
{% set outputStr = startId %}
{% set end = false %}
{% for i in 0..elements|length if end == false %}
{% set el = elements[outputInt] %}
{% if '+' in el.nextElement %}
{% set arr = el.nextElement|split('+') %}
{% set output = arr[0] + arr[1] %}
{% elseif '*' in el.nextElement %}
{% set arr = el.nextElement|split('*') %}
{% set output = arr[0] * arr[1] %}
{% elseif '/' in el.nextElement %}
{% set arr = el.nextElement|split('/') %}
{% set output = arr[0] / arr[1] %}
{% elseif '-' in el.nextElement %}
{% set arr = el.nextElement|split('-') %}
{% set output = arr[0] - arr[1] %}
{% else %}
{% set output = el.nextElement %}
{% endif %}
{% if el.nextElement is null %}
{% set end = true %}
{% set outputStr = outputStr ~ ' > ' ~ el.title %}
{% else %}
{% set outputInt = output %}
{% set outputStr = outputStr ~ ' > ' ~ output %}
{% endif %}
{% endfor %}
{{ outputStr }}
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment