lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I assume that I have to set _ENV for each chunk that possibly runs
> during template rendering (it can be many, and the idea is to call
> them repeatedly using different data tables). So this would mean to
> fixup _ENV for each chunk everytime the render() function is called?

When you convert templates to Lua code, add this line at the top of each script:
	local _ENV = ...

(That's three dots as in varargs.)
Then you can run each script passing a suitable table as its env at run time.