mirror of
https://github.com/pantor/inja.git
synced 2026-04-28 02:09:26 +00:00
Add Child Inheritance Feature (#198)
* add block and extend feature * constify, code cleaning * update single include * add html language to readme * clean tests * constantify, update year
This commit is contained in:
11
test/data/html-extend/base.txt
Normal file
11
test/data/html-extend/base.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{% block head -%}
|
||||
<title>{% block title %}Default - {% endblock %}</title>
|
||||
{%- endblock -%}
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}ignored{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
12
test/data/html-extend/data.json
Normal file
12
test/data/html-extend/data.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"author": "Pantor",
|
||||
"date": "23/12/2018",
|
||||
"tags": [
|
||||
"test",
|
||||
"templates"
|
||||
],
|
||||
"views": 123,
|
||||
"title": "Inja works.",
|
||||
"content": "Inja is the best and fastest template engine for C++. Period.",
|
||||
"footer-text": "This is the footer."
|
||||
}
|
||||
3
test/data/html-extend/inter.txt
Normal file
3
test/data/html-extend/inter.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
{% extends "base.txt" %}
|
||||
{% block title %}Inter {{ author }}{% endblock %}
|
||||
{% block body %}<main>Intermediate Content</main>{% endblock %}
|
||||
11
test/data/html-extend/result.txt
Normal file
11
test/data/html-extend/result.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Default - Inter Pantor: Inja works.</title>
|
||||
|
||||
<style type="text/css">.important { color: #336699; }</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>Inja is the best and fastest template engine for C++. Period.</main>
|
||||
</body>
|
||||
</html>
|
||||
7
test/data/html-extend/template.txt
Normal file
7
test/data/html-extend/template.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
{% extends "inter.txt" %}
|
||||
{% block head -%}
|
||||
{{ super(2) }}
|
||||
<style type="text/css">.important { color: #336699; }</style>
|
||||
{%- endblock %}
|
||||
{% block title %}{{ super(2) }}{{ super() }}: {{ title }}{% endblock %}
|
||||
{% block body %}<main>{{ content }}</main>{% endblock %}
|
||||
Reference in New Issue
Block a user