Make the templating system work(!)
This commit is contained in:
parent
4e64d9e340
commit
7563f1058b
7 changed files with 124 additions and 12 deletions
|
@ -4,15 +4,26 @@ import os
|
|||
|
||||
def _render_section_room_events(env, units):
|
||||
template = env.get_template("events.tmpl")
|
||||
return template.render(example=example, event=event)
|
||||
examples = units.get("event-examples")
|
||||
schemas = units.get("event-schemas")
|
||||
sections = []
|
||||
for event_name in schemas:
|
||||
sections.append(template.render(
|
||||
example=examples[event_name],
|
||||
event=schemas[event_name]
|
||||
))
|
||||
return "\n\n".join(sections)
|
||||
|
||||
SECTION_DICT = {
|
||||
"room-events": _render_section_room_events
|
||||
"room_events": _render_section_room_events
|
||||
}
|
||||
|
||||
def load(env, units):
|
||||
store = AccessKeyStore()
|
||||
for unit_key in SECTION_DICT:
|
||||
unit = SECTION_DICT[unit_key](env, units)
|
||||
store.add(unit_key, unit)
|
||||
for section_key in SECTION_DICT:
|
||||
section = SECTION_DICT[section_key](env, units)
|
||||
print "Generated section '%s' : %s" % (
|
||||
section_key, section[:60].replace("\n","")
|
||||
)
|
||||
store.add(section_key, section)
|
||||
return store
|
Loading…
Add table
Add a link
Reference in a new issue