aboutsummaryrefslogtreecommitdiff
path: root/docs/example-lua-plugin/main.lua
blob: eafd9dd6e84a4651dee3133dd844eb7cac6dd78e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
alps.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
alps.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
alps.set_filter("example_and", function(a, b)
    return a .. " and " .. b
end)