Skip to content

Instantly share code, notes, and snippets.

@dangh
Last active June 19, 2018 07:28
Show Gist options
  • Save dangh/011462356bc85e34b76039434f432c99 to your computer and use it in GitHub Desktop.
Save dangh/011462356bc85e34b76039434f432c99 to your computer and use it in GitHub Desktop.
LuCI annotation

Source: https://github.com/openwrt/luci/blob/e380cf51f8d60193f5743651f3c683389e4ef211/modules/luci-base/src/template_parser.c#L196-L232

code description
<%_ term %> translate with i18n
<%: term %> translate with i18n and escape XML
<%+ path/to/template %> include template from view dir (/usr/lib/lua/luci/view)
<%= expression %> print expression
<%# comment %> comment
<%- remove whitespaces on the left
-%> remove whitespaces on the right

Example:

<title>
  <%-= "Hello World" -%>
</title>

Result:

<title>Hello World</title>

<%+ path/to/template %> will be expanded to include("path/to/template") with include is provided at runtime by the dispatcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment