[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Setting globals in the C API
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 2 Aug 2016 15:37:39 -0300
> 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.