Add documentation converted from old Trac wiki pages
[project/luci.git] / documentation / Templates.md
1 LuCI has a simple regex based template processor which parses HTML-files to Lua functions and allows to store precompiled template files.
2 The simplest form of a template is just an ordinary HTML-file. It will be printed out to the user as is.
3
4 In LuCI every template is an object with an own scope. It can therefore be instanciated and each instance can has a different scope. As every template processor. LuCI supports several special markups. Those are enclosed in *<% %>-Tags*.
5
6 By adding a *-_' right after the opening '''<%''' every whitespace before the markup will be stripped. Adding a '''-''' right before the closing '_%>* will equivalently strip every whitespace behind the markup.
7
8 <<BR>>
9
10
11 # Builtin functions and markups
12 ## Including Lua code
13 *Markup:*
14
15 <% code %>
16
17
18
19 ## Writing variables and function values
20 *Syntax:*
21
22 <% write (value) %>
23
24
25 *Short-Markup:*
26
27 <%=value%>
28
29
30 ## Including templates
31 *Syntax:*
32
33 <% include (templatename) %>
34
35
36 *Short-Markup:*
37
38 <%+templatename%>
39
40
41
42 ## Translating
43 *Syntax:*
44
45 <%= translate("Text to translate") %>
46
47
48
49 *Short-Markup:*
50
51 <%:Text to translate%>
52
53
54
55 ## Commenting
56 *Markup:*
57
58 <%# comment %>
59
60
61 # Builtin constants
62 ||*Name_'||'_Value*||
63 ||REQUEST_URI||The current URL (without server part)||
64 ||controller||Path to the Luci main dispatcher||
65 ||resource||Path to the resource directory||
66 ||media||Path to the active theme directory||