Warning: Undefined variable $script in /home/public/wiki.obormot.net/cookbook/luaexecute.php on line 28
New OborWiki feature: Lua code execution — OborWiki
Blog »

New OborWiki feature: Lua code execution

December 31, 2017, at 06:21 PM by Obormot in Features, Updates (0 comments)

The Lua Execute recipe is now installed on OborWiki (off by default; you can enable it via the Configurator). It allows you to embed Lua code blocks in a wiki page, which are executed, and their output displayed when the page is rendered.

Here's an example:

(:lua:)
function demo()
 print('Counting from 1 to 5...')
 for v = 1, 5 do
  print(v)
 end
end

demo()
print('Today is '..os.date())
print('Pi is '..math.pi)
print('It works! <o>') -- By default, HTML is not allowed
print('')
print('This content was generated by '.._VERSION..'.')
(:luaend:)

NOTE: If you'd like to specify an initialization script to be run prior to every Lua code block, let me know (as that is currently a config option only I can modify, since it involves editing config.php).

See the Lua Execute recipe info page for more information.

Leave a reply
Your name (required):

Your comment (required):


Enter value: Captcha