You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lua@Client is focused in helping bring the Lua programming language to the web and browser. This project extends the .lp preprocessor to add support for new opening tags:
<?lua@client, <?lua@server, and <?lua@both.
The tag <?lua@client converts the code to client-side Lua, <?lua@server works the same as <?lua without the @ complement, and <?lua@both allows to mix client and server-side Lua code.
Lua@Client can be used with mod_lua, CGILua and projects that use the lp.lua library. It is also integrated and bundled with the latest release of the Sailor MVC Lua Framework.
To make the client-side Lua usage possible, the project integrates and extends a Lua VM allowing usage of browser-specific JavaScript objects (such as document, window, etc) from Lua. Currently, four different VMs are supported. You can also use Lua@Client without any preprocessors, from static HTML pages (see the examples folder for some simple example usage).
Lua@Client also provides on-the-fly conversion of Lua modules to JavaScript.
Development Status
This project is still beta. All input, feedback and contributions are highly appreciated.
##Installation
###Installation for Apache with mod_lua
Copy the JavaScript files from the js directory in this repository to a public area of your website.
Change the vm_url value in latclient\conf.lua. It must point to the URL where your copy of the JS files can be found.
Copy latclient.lua and the latclient subdirectory (which contains the lp_*.lua files) to the lua directory.
With Apache HTTPd <2.4.9, the FallbackResource directive should preferably not be used in the active virtual host, as it invalidates the LuaMapHandler directive.
###Installation with Sailor
Lua@Client comes bundled with the Sailor MVC Lua Framework, so you may prefer this route. Sailor is currently compatible with Apache with mod_lua or mod_pLua, Nginx with ngx_lua, Lwan, Lighttpd with mod_magnet, or any CGI-enabled web server, like Civetweb, Mongoose and Xavante, if CGILua is present.
Install Sailor, merge the test/dev-app application with the default Sailor app, and simply point your browser to ?r=test/starlight to see it in action.
###Installation for CGILua
Copy the JavaScript files from the js directory in this repository to a public area of your website.
Change the vm_url value in latclient\conf.lua. It must point to the URL where your copy of the JS files can be found.
Copy latclient.lua and the latclient directory contents to the lua directory.
Edit cgilua\lp.lua and: add local lat = require "latclient" to the beginning of the file and add s = lat.translate(s) as the first line of the translate function (see the lp_mod.lua file for an example).
Done! You can create your first .lp script using <?lua@
Usage Examples
Lua@Client usage will vary slightly according to the assigned Lua VM.