-
Notifications
You must be signed in to change notification settings - Fork 206
Closed
Labels
Description
Dude, I can't use google groups now. So let's talk here. the original post is here.
Actually I am using your lua-resty-template. It does support father-son inheritance. But note my example, it's actually grandfather-father-son inheritance which is not supported if I'm not wrong. for example:
base.html
<html lang='zh'>
<head>
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
{* blocks.content *}
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
home.html
{% layout = "base.html" %}
{-content-}This is Home!{-content-}
{* blocks.addition *}
page.html
{% layout = "home.html" %}
{-addition-}This is addtion..{-addition-}
test.lua
local res = require"resty.template".compile("home.html"){} --this will work as expected
local res = require"resty.template".compile("page.html"){} -- this will not work. additon block will be ignored.
在 2016年6月14日星期二 UTC+8上午5:17:52,Aapo Talvensaari写道:
On Monday, 13 June 2016 04:33:09 UTC+3, 项楠 wrote:
I'm looking for something similar to the directive `{% extends "base.html" %}` in Jinja2 template engine. I've read the docs of tt2, but `block`,`process`, `include` and `wrapper` are all seems not to be for template inheritance.
I don't mean to hijack this thread, but everything you describe is supported in lua-resty-template:
https://github.com/bungle/lua-resty-template
Syntax os a bit different though:
1.
{% extends "layout2.html" %}
=>
{% layout = "layout2.html" %}
2.
{% block nav %}<div class="nav"></div>{% endblock %}
=>
{-nav-}<div class="nav"></div>{-nav-}
3.
{% block nav %} {% endblock %}
=>
{* blocks.nav *}
etc.