lua-users home
lua-l archive

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

One of the intriguing things about doing this in Lua is that when you associate a function with each tag, you could use the environment of that function to store attributes atttached to that they become "globals" for that tags function and its children. To make this really useful, though, the environments would also have to be chained via __index, or a bridging global such as _parent...

setfenv(newTag, {_parent = getfenv(1)})

...or something along those lines.


On Feb 11, 2010, at 2:13 PM, Patrick wrote:

> Thanks very much Guys
> This is working for me, I just might try to tweak it a bit so that it uses all return or print statements:
> function one()
> print([[long long string]] .. (function() return "blah" end)() ..
> [[more of the long string]])
> end
> I write terrible, verbose emails but just to explain the madness here. I am trying to convert XML documents, namely HTML and SVG from a series of nested tags to a series of nested functions. My hope is that I can use it for a templating "language". I could feed in a single table and then use lexical scoping within the nested functions to return a given value.
> i.e quick garbage psuedo code
> Function one return <head> get doctype from table or return doctype......<title> function two get title from table or .....</title> </head>
> Thanks again for all your help, I will post back if anything I create looks even the slightest bit useful :-) Patrick