[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: using cgilua for my own little scripting purposes
- From: "Andre Carregal" <carregal@...>
- Date: Fri, 5 Aug 2005 19:27:29 -0300
> Robert Raschke wrote:
> I found myself recently needing to write a small program that would
> allow simple parameter substitution in a text file with values found
> in a DB. I started out by using the $ substitution routine from PIL
> (p.169) and global variables fed by an SQL select statement.
> I can now "just" call the script() function and write my template file
> in lovely cgi manner (with loops, conditionals, and the whole power of
> lua at my fingertips). And I can "sell" it much more easily to the
> people who may end up having to write some of these templates: "It's
> just like VBScript, just a bit simpler ..." ;-)
> It only took a little bit of experimentation to get the error handling
> to not constantly chatter html at me.
It seems that what you are looking for is a template engine, not the whole
CGILua library. CGILua includes a template engine for Lua Pages (lp.lua) but
also includes lots of Web stuff that surely gets in the way when the
expected results are text only.
Maybe you can try just using LP itself as in:
lp = require"cgilua.lp"
results = lp.translate(source)
Where "myfunc" is the name of your output function and source is the
template text. The output function will be called for every chunk of text
that is not Lua.