I am not sure if this is an issue with express or wether I am doing something wrong with nunjucks. I want to create a template hierarchy where template contains all the commons parts and specific pages extend template. For some reason the body field is block. If I change extend directive to include inside the template.nunj everything works properly but I can't extend header. I also tried explicitly declaring the header block in template.nunj and index.nunj and called super() but for some reason either the header or the body comes blank.
express setup:
nunjucks.configure(path.resolve(__dirname, '.', 'views'), {
autoescape: true,
express: app,
watch: true,
cache: false,
});
app.set('view engine', 'nunj');
layout.nunj:
<!DOCTYPE html>
<html lang="en">
{% extends './common/header.nunj' %}
<body>
<div class="container">
{% block mainContainer %}
<p>This should be working</p>
{% endblock %}
</div>
</body>
</html>
index.nunj
{% extends 'layout.nunj' %}
{% block mainContainer %}
{{ super() }}
<p>This should be rendering</p>
{% endblock %}
header.nunj
{% block header %}
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/style.css">
<title>Dari Dictionary</title>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
{% endblock %}