Inheritance
IwaiEngine supports file-based template composition through {% include %}, {% extends %}, and {% block %}.
Include
# views/list.iwai
<ul>{% include "item.iwai" %}</ul># views/item.iwai
<li>{{ item|upper }}</li>The included template receives the current render context plus any visible local variables defined with {% set %}.
Extends and Blocks
# views/base.iwai
<html>
<body>
{% block header %}<h1>Base</h1>{% end %}
{% block content %}<p>Base content</p>{% end %}
</body>
</html># views/page.iwai
{% extends "base.iwai" %}
{% block content %}
<p>Hello {{ name }}</p>
{% end %}using IwaiEngine
using Base.Filesystem: mktempdir
mktempdir() do dir
write(joinpath(dir, "base.iwai"), """
<html>
<body>
{% block content %}<p>Base content</p>{% end %}
</body>
</html>
""")
write(joinpath(dir, "page.iwai"), """
{% extends "base.iwai" %}
{% block content %}
<p>Hello {{ name }}</p>
{% end %}
""")
tpl = IwaiEngine.load(joinpath(dir, "page.iwai"))
println(tpl((name = "Iwai",)))
end<html>
<body>
<p>Hello Iwai</p>
</body>
</html>