The <code><lua></code> tag allows you to embed Lua code in your templates and wiki documents.

<source lang="lua">
<lua where="wall">
function bottle(x)
  if x > 1 then
    return x .. " bottles of beer"
  elseif x == 1 then
    return "One bottle of beer"
  else
    return "No more bottles of beer"
  end
end

function count(x)
  output = "<pre>"
  for beer = x, 1, -1 do
    output = output .. bottle(beer) .. " on the " .. where .. ",\n"
    output = output .. bottle(beer) .. ",\n"
    output = output .. "Take one down, pass it around,\n"
    output = output .. bottle(beer-1) .. " on the " .. where .. ".\n"
    output = output .. "\n\n"
  end
  return output .. "</pre>"
end
</lua>

 ==99 Bottles of Beer==
{{#luaexpr:count(99)}}
</source>

==In Action==
<lua where="floor">
function bottle(x)
  if x > 1 then
    return x .. " bottles of beer"
  elseif x == 1 then
    return "One bottle of beer"
  else
    return "No more bottles of beer"
  end
end

function count(x)
  output = "<pre>"
  for beer = x, 1, -1 do
    output = output .. bottle(beer) .. " on the " .. where .. ",\n"
    output = output .. bottle(beer) .. ",\n"
    output = output .. "Take one down, pass it around,\n"
    output = output .. bottle(beer-1) .. " on the " .. where .. ".\n"
    output = output .. "\n\n"
  end
  return output .. "</pre>"
end
</lua>

==99 Bottles of Beer==
{{#luaexpr:count(99)}}
