Add templating folder and stub files/templates.
parent
bfec7752cb
commit
0b8b77697b
@ -0,0 +1,21 @@
|
|||||||
|
This folder contains the templates and templating system for creating the spec.
|
||||||
|
We use the templating system Jinja2 in Python. This was chosen over other
|
||||||
|
systems such as Handlebars.js and Templetor because we already have a Python
|
||||||
|
dependency on the spec build system, and Jinja provides a rich set of template
|
||||||
|
operations beyond basic control flow.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
```
|
||||||
|
$ pip install Jinja2
|
||||||
|
```
|
||||||
|
|
||||||
|
Running
|
||||||
|
-------
|
||||||
|
To build the spec:
|
||||||
|
```
|
||||||
|
$ python build.py
|
||||||
|
```
|
||||||
|
|
||||||
|
This will output ``spec.rst`` which can then be fed into the RST->HTML
|
||||||
|
converter located in ``matrix-doc/scripts``.
|
@ -0,0 +1,18 @@
|
|||||||
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
import json
|
||||||
|
|
||||||
|
def jsonify(input):
|
||||||
|
return json.dumps(input, indent=4)
|
||||||
|
|
||||||
|
env = Environment(loader=FileSystemLoader("templates"))
|
||||||
|
env.filters["jsonify"] = jsonify
|
||||||
|
|
||||||
|
example = {}
|
||||||
|
with open("../example.json", "r") as f:
|
||||||
|
example = json.loads(f.read())
|
||||||
|
event = {}
|
||||||
|
with open("../event_schema.json", "r") as f:
|
||||||
|
event = json.loads(f.read())
|
||||||
|
|
||||||
|
template = env.get_template("events.tmpl")
|
||||||
|
print template.render(example=example, event=event)
|
@ -0,0 +1,7 @@
|
|||||||
|
{{event.type}}
|
||||||
|
--------------
|
||||||
|
Summary: {{event.summary}}
|
||||||
|
Type: {{event.parent}}
|
||||||
|
Description: {{event.desc}}
|
||||||
|
JSON Format: {{event.content | jsonify}}
|
||||||
|
Example: {{example.content | jsonify}}
|
Loading…
Reference in New Issue