lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sun, Jan 10, 2010 at 12:09 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Sun, Jan 10, 2010 at 3:56 PM, Cosmin Apreutesei
> <cosmin.apreutesei@gmail.com> wrote:
>> Problem is, I don't see how orbit.htmlize() can still be implemented in 5.2 :(
>
> Good question. Would badly miss that one!
>

Something like this could be made to work with getfenv and in:

----------
local orbit = require "orbit"

in module("foo") do
  ...

  in orbit.htmlify() do

    function my_view()
      return html{ body{ p "foo" } }
    end

  end

  function my_controller(web)
    return my_view()
  end

  ...
end
----------

Without getfenv you have to resort to something like:

----------
in module("foo") do
  ...

  local _M = _M

  in orbit.htmlify() do

    function _M.my_view()
      return html{ body{ p "foo" } }
      -- all globals here would be html tags
    end

  end

  function my_controller(web)
    return my_view()
  end

end
----------

I can see myself getting used to this style after a while, but it sure
is more cumbersome.

--
Fabio Mascarenhas