httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From HyperHacker <hyperhac...@gmail.com>
Subject Re: a plan mod_lua and 2.4
Date Tue, 15 Mar 2011 14:50:36 GMT
On Tue, Mar 15, 2011 at 08:05, Dan Poirier <poirier@pobox.com> wrote:
> On Tue. 2011-03-15 at 09:36 AM EDT, HyperHacker <hyperhacker@gmail.com> wrote:
>
>> I've been eagerly looking forward to a stable mod_lua with which to
>> make my sites. If done well, Lua could replace PHP as the #1 web
>> scripting language
>
> Maybe if people could embed lua in web pages.
>

Mm, personally I dislike the "embed code in HTML" thing, as I'm one of
those purists who likes to keep code, presentation, and data separate.
However I did, just for fun, write a web server in Lua which had that
capability. It basically just did a gsub on the HTML file being sent:
str = str:gsub('<%?lua%s.-%s%?>',
	function(code)
		local func = loadstring(code:sub(7, -4))
		setfenv(func, self.Request.Environment)
		return tostring(func())
	end)

This is one of the things I love about Lua - once you have the
language, whatever additional functionality you want can be
implemented pretty easily. Little is built in. I imagine you could
work this into your mod_lua configuration fairly easily, and there you
go, code embedded within pages.

-- 
Sent from my toaster.

Mime
View raw message