webmcp

view libraries/nihil/nihil.lua @ 11:d76a8857ba62

Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link

Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"

Documentation for added functions is not yet complete.
author jbe/bsw
date Fri Feb 12 18:40:22 2010 +0100 (2010-02-12)
parents 9fdfb27f8e67
children 3d43a5cf17c1
line source
1 #!/usr/bin/env lua
3 local error = error
4 local getmetatable = getmetatable
5 local module = module
6 local rawset = rawset
7 local setmetatable = setmetatable
9 module(...)
11 metatable = {
12 __tostring = function(self)
13 return "nil" .. self[1]
14 end,
15 __newindex = function()
16 error("Objects representing nil are immutable.")
17 end
18 }
20 nils = setmetatable({}, {
21 __mode = "v",
22 __index = function(self, level)
23 if level > 0 then
24 local result = setmetatable({ level }, metatable)
25 rawset(self, level, result)
26 return result
27 end
28 end,
29 __newindex = function()
30 error("Table is immutable.")
31 end
32 })
34 function lift(value)
35 if value == nil then
36 return nils[1]
37 elseif getmetatable(value) == metatable then
38 return nils[value[1]+1]
39 else
40 return value
41 end
42 end
44 function lower(value)
45 if value == nil then
46 error("Cannot lower nil.")
47 elseif getmetatable(value) == metatable then
48 return nils[value[1]-1]
49 else
50 return value
51 end
52 end

Impressum / About Us