Module "upnp.lp
"
Lua Pages template engine. Code was taken from LuaDoc and adapted for LuaUPnP.
Copyright © 2004-2007 The Kepler Project, LuaUPnP modifications 2012 Thijs Schreijer, LuaUPnP
Release: Version 0.x, LuaUPnP.
Functions
__call (name, env) | Translates and executes a template in a given 'module' or file. |
lp.compile (str, chunkname) | Translates a template into a compiled Lua function. |
lp.includefile (filename, env) | Translates and executes a template in a given file. |
lp.includemodule (template, env) | Translates and executes a template in a given 'module'. |
lp.setoutfunc (f) | Defines the name of the output function. |
lp.translate (s) | Translate the template to Lua code. |
Functions
- __call (name, env)
-
Translates and executes a template in a given 'module' or file. This method enables to call directly on the module table. It will first call
lp.includefile()
, and if that failslp.includemodule()
Parameters:
-
name
: the file or module name. -
env
: Table with the environment to run the resulting function.
Return value:
the results ornil + errormsg
-
- lp.compile (str, chunkname)
-
Translates a template into a compiled Lua function. Does NOT execute the resulting function.
Parameters:
-
str
: String with the template to be translated. -
chunkname
: String with the name of the chunk, for debugging purposes.
Return value:
Function with the resulting translation. -
- lp.includefile (filename, env)
-
Translates and executes a template in a given file. The translation creates a Lua function which will be executed in an optionally given environment.
Parameters:
-
filename
: String with the name of the file containing the template. Once compiled the template function will be cached, based on the filename. -
env
: Table with the environment to run the resulting function. Ifnil
then a new environment will be used, both the new and the provided environment will be equipped with the basic Lua functions.
Return value:
the results of the function set bylp.setoutfunc()
, but might also throw an error -
- lp.includemodule (template, env)
-
Translates and executes a template in a given 'module'. It will search for a file located in the module path. It will look for a
'.upnp'
extension The translation creates a Lua function which will be executed in an optionally given environment (will call thelp.includefile()
function).Parameters:
-
template
: String with the name of the module containing the template. -
env
: Table with the environment to run the resulting function.
Return value:
the results of the function set bylp.setoutfunc()
, but might also throw an error -
- lp.setoutfunc (f)
-
Defines the name of the output function.
Parameters:
-
f
: String with the name of the function which produces output. Default value is"return"
.
-
- lp.translate (s)
-
Translate the template to Lua code.
Parameters:
-
s
: String to translate.
Return value:
String with translated, but not compiled, code. -