Jinja: TypeError: 특수 호좜자 μΈμˆ˜μ— λŒ€ν•΄ 두 개의 κ°’μœΌλ‘œ λ§€ν¬λ‘œκ°€ ν˜ΈμΆœλ˜μ—ˆμŠ΅λ‹ˆλ‹€. 이것은 버그일 κ°€λŠ₯성이 λ†’μŠ΅λ‹ˆλ‹€.

에 λ§Œλ“  2017λ…„ 02μ›” 02일  Β·  2μ½”λ©˜νŠΈ  Β·  좜처: pallets/jinja

μ˜ˆμƒλ˜λŠ” λ™μž‘

맀크둜 μž‘λ™!

μ‹€μ œ 행동

TypeError: 맀크둜 'google_analytics'κ°€ 특수 호좜자 μΈμˆ˜μ— λŒ€ν•΄ 두 개의 κ°’μœΌλ‘œ ν˜ΈμΆœλ˜μ—ˆμŠ΅λ‹ˆλ‹€. 이것은 버그일 κ°€λŠ₯성이 λ†’μŠ΅λ‹ˆλ‹€.

ν…œν”Œλ¦Ώ μ½”λ“œ

<!-- macros.html -->
{% macro google_analytics() %}
  <!-- Google Analytics script -->
{% endmacro %}


<!-- basic.html -->
{% extends 'layout/base.html' %}
{% from 'macros.html' import google_analytics %}

{% block grid %}
  {% block content %}{% endblock %}
  {% call google_analytics() %}{% endcall %}
{% endblock %}

전체 역좔적

127.0.0.1 - - [02/Feb/2017 21:21:14] "GET / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1994, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\_compat.py", line 33, in reraise
    raise value
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\_compat.py", line 33, in reraise
    raise value
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "d:\Project\source\views\site.py", line 236, in index
    return render_template('site/index.html', form=form)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\templating.py", line 134, in render_template
    context, ctx.app)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\flask\templating.py", line 116, in _render
    rv = template.render(context)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\jinja2\environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Compilers and Interpreters\Python35\lib\site-packages\jinja2\_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "d:\Project\source\templates\site\index.html", line 1, in top-level template code
    {% extends 'layout/basic.html' %}
  File "d:\Project\source\templates\layout\basic.html", line 2, in top-level template code
    {% from 'macros.html' import google_analytics %}
  File "d:\Project\source\templates\layout\base.html", line 29, in top-level template code
    {% block grid %}{% endblock %}
  File "d:\Project\source\templates\layout\basic.html", line 6, in block "grid"
    {% call google_analytics() %}{% endcall %}
TypeError: macro 'google_analytics' was invoked with two values for the special caller argument.  This is most likely a bug.

λ‹Ήμ‹ μ˜ ν™˜κ²½

  • Python 버전: Python 3.5.2
  • Jinja 버전: Jinja2(2.9.5)

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

{% call %} ν•˜μ§€ μ•ŠλŠ” ν…œν”Œλ¦Ώμ—μ„œλŠ” caller() κ°€ μž‘λ™ν•˜μ§€ μ•ŠλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. λ”°λΌμ„œ ν…œν”Œλ¦Ώμ΄ 잘λͺ»λ˜μ—ˆμ§€λ§Œ JinjaλŠ” λŒ€μ‹  의미 μžˆλŠ” 였λ₯˜λ₯Ό λ°œμƒμ‹œμΌœμ•Ό ν•©λ‹ˆλ‹€.

λͺ¨λ“  2 λŒ“κΈ€

{{ google_analytics() }}

{% call %} ν•˜μ§€ μ•ŠλŠ” ν…œν”Œλ¦Ώμ—μ„œλŠ” caller() κ°€ μž‘λ™ν•˜μ§€ μ•ŠλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. λ”°λΌμ„œ ν…œν”Œλ¦Ώμ΄ 잘λͺ»λ˜μ—ˆμ§€λ§Œ JinjaλŠ” λŒ€μ‹  의미 μžˆλŠ” 였λ₯˜λ₯Ό λ°œμƒμ‹œμΌœμ•Ό ν•©λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰