Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SWIFTweb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTweb
Commits
7f1fc6a0
Commit
7f1fc6a0
authored
7 years ago
by
Josh Borrow
Browse files
Options
Downloads
Patches
Plain Diff
Added jinja2 initial template and our new system
parent
9f1a207f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/compiler.py
+24
-0
24 additions, 0 deletions
templates/compiler.py
templates/pubs.jinja
+22
-0
22 additions, 0 deletions
templates/pubs.jinja
with
46 additions
and
0 deletions
templates/compiler.py
0 → 100644
+
24
−
0
View file @
7f1fc6a0
"""
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
())
This diff is collapsed.
Click to expand it.
templates/pubs.jinja
0 → 100644
+
22
−
0
View file @
7f1fc6a0
<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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment