lua-users home
lua-l archive

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


On Sun, May 11, 2008 at 10:21 PM, Tomas Guisasola Gorham
<tomas@tecgraf.puc-rio.br> wrote:
>         Hi Gustavo
>
>
>
> >
> > >  require"package.module.template".  The template should be found
> > >  the same way the module is.
> > >
> > Think of an XML template.  There are other examples of why this
> > is interesting too, but all of them relate to how finding paths
> > relative to the loaded module is useful.
> >
>         You may take a look at LuaDoc.  It has some HTML
>  templates installed as Lua modules.  I think it works very
>  well.

Actually, that trick use of the module system in LuaDoc was something
we needed to work around in LuaRocks, because package.path (which you
guys parse in LuaDoc and manually scan to search for resource files)
may be already reset by the time the module function is executed. (See
the patch we're applying at:
http://luarocks.luaforge.net/rocks/luadoc-3.0.1-1.rockspec ).

Overall, I support Gustavo's idea. One may want to know the locations
for loaded Lua modules in order to reuse their "prefix" to load other
files, but not use require() on these files. This is the kind of
information that could be hardcoded at install time (by a Makefile,
etc.) but it would be nicer (and in case of modules redistributed in
binary form, even necessary) to be able to obtain it dynamically.

-- Hisham