[luci] LuCI -> JavaScript data exchange
Steven Barth
steven at midlink.org
Wed Jul 8 14:24:38 CEST 2009
Hi Chris,
if you have the vis-table already as a JSON string you can simply do a:
<%=vis%> inside the template to place the content there.
If you however want to convert a native lua table into a JSON-string to use it
in a template, you can use the following chunk of code:
jsonSource = require "luci.json".Encoder(TableToBeConverted):source()
and pass it to the template.
In your template use:
<-%
local chunk = jsonSource()
while chunk do
write(chunk)
chunk = jsonSource()
end
%->
at the place where you want to have the JSON-data to be inserted.
Regards
Steven
More information about the luci
mailing list