Skip to content
Snippets Groups Projects
Commit 7f1fc6a0 authored by Josh Borrow's avatar Josh Borrow
Browse files

Added jinja2 initial template and our new system

parent 9f1a207f
No related branches found
No related tags found
No related merge requests found
""" Short compilation script from the website (essentially just stitches together a bunch of jinja templates) """
import jinja2
import yaml
def get_from_filesystem(template_name, template_dir="."):
""" Grab a template from the filesystem and return the template object ready for rendering """
template_loader = jinja2.FileSystemLoader(searchpath=template_dir)
template_env = jinja2.Environment(loader=template_loader)
return template_env.get_template(template_name)
def compile_pubs(template_name="pubs.jinja", template_dir=".", data_dir="../data"):
""" Render the pubs page """
template = get_from_filesystem(template_name, template_dir)
with open("{}/pubs.yaml".format(data_dir), 'r') as f:
cards = yaml.load(f)
return template.render(cards=cards)
if __name__ == "__main__":
print(compile_pubs())
<html>
<head>
</head>
<body>
<div class="container">
<div class="cards">
{% for card in cards %}
<div class="card">
<div class="card-content">
<img src="{{ card.img }}">
<h3>{{ card.title }}</h3>
<p>{{ card.date }}</p>
</div>
</div>
{% endfor %}
</div>
</div>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment