aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-02-11 17:56:15 +0100
committerSimon Ser <contact@emersion.fr>2020-02-11 17:56:15 +0100
commite09a83756922a2c7855c0b7159fdd12b87153cd4 (patch)
tree97fd0dd8ec6988b177ac0f25864d8ea031c89321
parent0a56365672dab47d27a57d703aeb33477c60b10c (diff)
downloadalps-e09a83756922a2c7855c0b7159fdd12b87153cd4.tar.gz
alps-e09a83756922a2c7855c0b7159fdd12b87153cd4.zip
docs: add a basic example Lua plugin
-rw-r--r--docs/example-lua-plugin/main.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/example-lua-plugin/main.lua b/docs/example-lua-plugin/main.lua
new file mode 100644
index 0000000..8df1ec6
--- /dev/null
+++ b/docs/example-lua-plugin/main.lua
@@ -0,0 +1,19 @@
+-- This message will be printed when the plugin is loaded
+print("Hi, this is an example Lua plugin")
+
+-- Setup a function called when the mailbox view is rendered
+koushin.on_render("mailbox.html", function(data)
+ print("The mailbox view for " .. data.Mailbox.Name .. " is being rendered")
+ -- Set extra data that can be accessed from the mailbox.html template
+ data.Extra.Example = "Hi from Lua"
+end)
+
+-- Wire up a new route
+koushin.set_route("GET", "/example", function(ctx)
+ ctx:String(200, "This is an example page.")
+end)
+
+-- Set a filter function that can be used from templates
+koushin.set_filter("example_and", function(a, b)
+ return a .. " and " .. b
+end)