Sha256: be34f55fa515f84739a91bc343eedb0e7f422b30cd1f4a7778b1a1155dae05af

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

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)}}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wikicloth-0.8.3 sample_documents/lua.wiki
wikicloth-0.8.2 sample_documents/lua.wiki
wikicloth-0.8.1 sample_documents/lua.wiki
wikicloth-0.8.0 sample_documents/lua.wiki