webmcp

view framework/env/format/boolean.lua @ 28:ea2e8f3a2776

allow webmcp path to be set in cgi script

this allows another script to include the webmcp script when the cwd is not the cgi-bin. the script needs to set the WEBMCP_PATH variable.
author Daniel Poelzleithner <poelzi@poelzi.org>
date Sun Sep 19 01:36:08 2010 +0200 (2010-09-19)
parents 9fdfb27f8e67
children
line source
1 --[[--
2 text = -- human text representation of the boolean
3 format.boolean(
4 value, -- true, false or nil
5 {
6 true_as = true_text, -- text representing true
7 false_as = false_text, -- text representing false
8 nil_as = nil_text -- text representing nil
9 }
10 )
12 Returns a human readable text representation of a boolean value. Additional parameters should be given, unless you like the defaults for false and true, which are "0" and "1".
14 --]]--
16 function format.boolean(value, options)
17 local options = options or {}
18 local true_text = options.true_as or "Yes" -- TODO: localization?
19 local false_text = options.false_as or "No" -- TODO: localization?
20 local nil_text = options.nil_as or ""
21 if value == nil then
22 return nil_text
23 elseif value == false then
24 return false_text
25 elseif value == true then
26 return true_text
27 else
28 error("Value passed to format.boolean(...) is neither a boolean nor nil.")
29 end
30 end

Impressum / About Us