Reference

Data passed to the template:

{
    name='world',
    list={'foo', 'bar', 'baz'},
    truthy=true,
}
Name Input Output

Just text, single line

Hello world
Hello world

Just text, no newline at end of file

No NL at EOF in the template (but present in the output)
No NL at EOF in the template (but present in the output)

Just text, multiple lines

Hello
world
Hello
world

Just code 1

% --[[ nothing to see here ]]

Just code 2

<% --[[ nothing to see here ]] %>

Just code 3

<% if false then end %>

Basic substitution 1

Hello <%=name%>
Hello world

Basic substitution 2

Hello <%=name%>!
Hello world!

Repeated substitution 1

Hello <%=name%><%=name%>
Hello worldworld

Repeated substitution 2

Hello <%=name%> and <%=name%>
Hello world and world

Multiline substitution 1

Hello <%=
name%>
Hello world

Multiline substitution 2

Hello <%=
name
%>
Hello world

Multiline substitution 3

Hello <%=name
%>
Hello world

Mixed code and text 1

Hello<%
-- Ignored entirely
%> world
Hello world

Mixed code and text 2

Hello <%=
name
%>!
Hello world!

Mixed code and text 3

My list of items:
% for _, item in ipairs(list) do
* <%= item %>
% end
My list of items:
* foo
* bar
* baz

Mixed code and text and newlines 1

My list of items:
<% for _, item in ipairs(list) do %>
* <%= item %>
<% end %>
My list of items:

* foo

* bar

* baz

Mixed code and text and newlines 2

My list of items:
<% for _, item in ipairs(list) do
%>* <%= item %>
<% end %>
My list of items:
* foo
* bar
* baz

Complex mix

Hello <%= name %>
Here are your items:
% for i, item in pairs(list) do
* <%= item %>
% end


Normal text after two empty lines.
<% if true then %>This will be printed.<% end %>
<% if false then %>This will NOT be printed.<% end %>
Hello world
Here are your items:
* foo
* bar
* baz


Normal text after two empty lines.
This will be printed.

Print delimiters

Start delimiter: <%= '<%' %>
Closing delimiter: <%= '%' .. '>' %>
Start delimiter: <%
Closing delimiter: %>