1
jinja 템플릿에서 파이썬 함수를 호출하려고합니다.Jinja2 - Set (Assignments)를 사용하여 customer_function 호출
{% set key, value = call_something() %}
을하지만, 다음과 같은 소스가 작동하지 않습니다 다음 doucmentation (http://jinja.pocoo.org/docs/2.10/templates/가 할당 참조)에서 다음의 예는 제공됩니다.
import jinja2
@jinja2.contextfunction
def hw():
return "World"
template = jinja2.Template('{% set test = hw() %} Hello {{ test }}!')
template.render(name='John Doe')
Error: ... UndefinedError: 'hw' is undefined
문제를 해결하는 방법을 아는 사람이 있습니까?! 모두에게 감사드립니다!