ํ์ฌ ์๋ณ์ ์ถ์ ์ ๋งค์ฐ ์กฐ์กํ๋ฉฐ ์ ๋์ฌ ๋ณ์๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค. ์์ด๋์ด๋ ์ผ๋ถ ๊ณ ์ ๋ณ์๋ฅผ ๋๋๋ฆด ์ ์๋ ๊ณ ์ ์๋ณ์๋ก ๋ค์ ์ฐ๋ ๊ฒ์ ๋๋ค.
์ด๋ ๊ฒ ํ๋ฉด ์ฝ๋ ์ ์ฒด์์ locals()๋ฅผ ์ฌ์ฉํ ํ์๊ฐ ์๊ณ ํจ์ ๊ฒฝ๊ณ๋ฅผ ๋์ด ์๋ณ์์ ๊ด๋ จ๋ ๋ช ๊ฐ์ง ๋ฌธ์ ๊ฐ ์์ ๋ฉ๋๋ค.
์ด ๋ฌธ์ ์ ์ํฅ์ ๋ฐ๋์ง ์ด๋ป๊ฒ ์ ์ ์์ต๋๊น? "Unbound variable l_SOMETHING"์ด ๋ฐ๊ฒฌ๋์์ต๋๋ค.
๋ฐฉ๊ธ #pocoo์์:
magicbronson: hey mitsuhiko et al., trying to render a Jinja template in a Flask app and getting a very mysterious message: "global name 'l_config' is not defined"
magicbronson: l_config appears nowhere in my code or libraries'
mitsuhiko: magicbronson: that's the scoping bug that i will fix over this summer
mitsuhiko: {% macro foo() %}{{ config }}{% for config in something_else %}{{config}}{% endfor %}{% endmacro %}
mitsuhiko: something like this triggers the bug currently
mitsuhiko: magicbronson: rename the variable inside of the macro to something else
mitsuhiko: {% set cfg = config %}
mitsuhiko: outside the macro
mitsuhiko: or something
Armin์ ์ ์์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
๋๋์ด ์๋ฃ๋์์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๋์ด ์๋ฃ๋์์ต๋๋ค.