lua-users home
lua-l archive

RE: Custom loaders using Lua file templates

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


Jerome Vuarand wrote:
> I really like Lua's file template mechanism ("foo/bar/?.xxx"). But it
> is only useful in searching for Lua or native modules. My system can
> also load XML files and I'd like to be able to "require" those files
> as well. There is a nice custom loader mechanism, but no access to
> the template parser. it wouldn't be hard to duplicate, but it would
> be nicer to be able to use the one that already exists. 
> 
> Has there been any thought to exposing the parser (specifically the
> findfile() method. Or is there some hidden way to use this that I am
> not seeing? Seems like it could be easily exposed directly: 
> 
> filename = package.findfile("myfile", "xmlpath")
> 
> where xmlpath is a template in package, just like 'path' and 'cpath'.
> 
> I can certainly add this to my local copy of Lua, but it would be
> really nice if this were a standard feature. 
Some time ago I put some searcher (that's the name of the things in
package.loaders, counter-intuitively) examples on the wiki:
http://lua-users.org/wiki/LuaModulesLoader
http://lua-users.org/wiki/HashedModulesLoader
First one just reimplements the default Lua module loader in Lua. The
second one adds some functionnality over that (here it checks the module
hash with LuaCrypto).

AltStyle によって変換されたページ (->オリジナル) /