Is there a way to evaluate a string to actual Jinja “code”?
Basically I want to be able to build a macro that allows passing in a string that is then evaluated in the current context.
{% macro run_query_as_code(my_query) %}
{% set results = run_query('select 123 as column_name') %}
{% for r in results.rows %}
{# Here I need my_query to be evaluated to jinja, not sure of the correct filter or function? #}
{{ my_query }}
{% endfor %}
{% endmacro %}
{{ run_query_as_code('hello {{ r["COLUMN_NAME"] }} ') }}
So ideally calling run_query_as_code('hello {{ r["foo"] }} ')
would return:
hello 123