{% 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