builtin tests with if or not do not work : Failed to render '__tera_one_off'
Hi,
I am using Tera in my application. It works well but I constates that builtin tests such as defined, object, string, etc. do not work. I tried to use them as below:
{{ result['subuser-create']['toto'] | defined }}
or
{% if result['subuser-create']['toto'] is defined %}...
I use render_str to render templates.
Can you tell me if there is any settings to do ?
Thanks for your helps.
NT
It looks like you're using Tera::one_off from the template name, how are you using render_str then?
I rendered this string:
"{\n \"subuser\": \"{{ context.data.tenant_id }}\",\n \"event\": \"SUBUSER_CREATED\",\n \"payload\": {},\n \"status\": 0,\n \"error\": {% if result['subuser-create']['output']['content']['errors'] is defined %}{{ result['subuser-create']['output']['content']['errors'] | json_encode() | safe }}{% else %}N/A{% endif %}\n}\n"
using : tera.render_str(s.as_str(), &context) for example.
Can you past the whole Tera instantiation and the error you get?
It looks like you're using Tera::one_off from the template name, how are you using
render_strthen?
Both render_str and one_off uses the same default name.