Skip to content

Instantly share code, notes, and snippets.

@abadc0de
abadc0de / ob_templates.md
Last active December 14, 2015 23:28
Lua page templates for HTML documents, with output buffering

Templating with output buffers

Output buffering can be used to create nested templates, allowing for reusable, organized content.

A simple template

In Lua pages, expect a free global variable (here, page) is a table with strings to inject. The "base" template might look like this:

<? print('HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n')

?>

@abadc0de
abadc0de / bicycle.lua
Last active June 5, 2016 04:14
Bicycle for Mongoose.
_G.bicycle = {
-- Add your form callbacks here.
action = { },
-- This will contain data parsed from the query string.
basket = { },
-- Configuration options. Set these before calling "ride" if needed.
config = {