Skip to content

Commit 289218f

Browse files
committed
translate templates from handlebars to tera
1 parent bfcf58a commit 289218f

File tree

7 files changed

+47
-38
lines changed

7 files changed

+47
-38
lines changed

templates/feed.tera

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
</author>
1313
<updated>{{feed_updated}}</updated>
1414

15-
{{#each posts}}
15+
{% for post in posts %}
1616
<entry>
17-
<title>{{title}}</title>
18-
<link rel="alternate" href="https://blog.rust-lang.org/{{../blog.prefix}}{{url}}" type="text/html" title="{{title}}" />
19-
<published>{{published}}</published>
20-
<updated>{{updated}}</updated>
21-
<id>https://blog.rust-lang.org/{{../blog.prefix}}{{url}}</id>
22-
<content type="html" xml:base="https://blog.rust-lang.org/{{../blog.prefix}}{{url}}">{{contents}}</content>
17+
<title>{{post.title}}</title>
18+
<link rel="alternate" href="https://blog.rust-lang.org/{{blog.prefix}}{{post.url}}" type="text/html" title="{{post.title}}" />
19+
<published>{{post.published}}</published>
20+
<updated>{{post.updated}}</updated>
21+
<id>https://blog.rust-lang.org/{{blog.prefix}}{{post.url}}</id>
22+
<content type="html" xml:base="https://blog.rust-lang.org/{{blog.prefix}}{{post.url}}">{{post.contents}}</content>
2323

2424
<author>
25-
<name>{{author}}</name>
25+
<name>{{post.author}}</name>
2626
</author>
2727
</entry>
28-
{{/each}}
28+
{% endfor %}
2929
</feed>

templates/footer.tera

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% macro footer(root) -%}
12
<footer>
23
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
34
<div class="row">
@@ -44,3 +45,4 @@
4445

4546
<!-- scripts -->
4647
<script src="{{root}}scripts/highlight.js"></script>
48+
{% endmacro %}

templates/headers.tera

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
{% macro headers(root, title, blog) -%}
12
<!-- Twitter card -->
23
<meta name="twitter:card" content="summary">
34
<meta name="twitter:site" content="@rustlang">
45
<meta name="twitter:creator" content="@rustlang">
5-
<meta name="twitter:title" content="{{title}}">
6+
<meta name="twitter:title" content="{{title | escape_hbs}}">
67
<meta name="twitter:description" content="{{blog.description}}">
78
<meta name="twitter:image" content="https://www.rust-lang.org/static/images/rust-social.jpg">
89

910
<!-- Facebook OpenGraph -->
10-
<meta property="og:title" content="{{title}}" />
11+
<meta property="og:title" content="{{title | escape_hbs}}" />
1112
<meta property="og:description" content="{{blog.description}}">
1213
<meta property="og:image" content="https://www.rust-lang.org/static/images/rust-social-wide.jpg" />
1314
<meta property="og:type" content="website" />
@@ -39,3 +40,4 @@
3940

4041
<!-- theme switcher -->
4142
<script src="{{root}}scripts/theme-switch.js"></script>
43+
{% endmacro %}

templates/index.tera

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
{{#*inline "page"}}
1+
{% extends "layout.tera" %}
2+
{% block page %}
23
<header class="mt3 mt0-ns mb4-ns">
34
<div class="container flex flex-column flex-row-l justify-between-l">
45
<div class="mw6-l">
5-
<p>{{{blog.index_html}}}</p>
6+
<p>{{blog.index_html}}</p>
67
</div>
78
</div>
89
<div class="container flex flex-column flex-row-l justify-between-l">
910
<div class="mw8-l">
1011
<p>
1112
<b>See also:</b>
12-
{{#each other_blogs}}
13-
<a href="{{../root}}{{url}}">{{link_text}}</a>
14-
{{/each}}
13+
{%- for other in other_blogs %}
14+
<a href="{{root}}{{other.url}}">{{other.link_text | escape_hbs}}</a>
15+
{%- endfor %}
1516
</p>
1617
</div>
1718
</div>
@@ -21,19 +22,18 @@
2122
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
2223

2324
<table class="post-list collapse w-100 f2-l f2-m f3-s">
24-
{{#each blog.posts}}
25-
{{#if show_year}}<tr>
25+
{%- for post in blog.posts %}
26+
{% if post.show_year %}<tr>
2627
<td class="bn"></td>
27-
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{year}}</h3></td>
28-
</tr>{{/if}}
28+
<td class="bn"><h3 class="f0-l f1-m f2-s mt4 mb0">Posts in {{post.year}}</h3></td>
29+
</tr>{% endif %}
2930
<tr>
30-
<td class="tr o-60 pr4 pr5-l bn">{{month_name month}}&nbsp;{{day}}</td>
31-
<td class="bn"><a href="{{url}}">{{title}}</a></td>
31+
<td class="tr o-60 pr4 pr5-l bn">{{post.month | month_name}}&nbsp;{{post.day}}</td>
32+
<td class="bn"><a href="{{post.url}}">{{post.title | escape_hbs}}</a></td>
3233
</tr>
33-
{{/each}}
34+
{%- endfor %}
3435
</table>
3536

3637
</div>
3738
</section>
38-
{{/inline}}
39-
{{~> layout~}}
39+
{%- endblock page %}

templates/layout.tera

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
{% import "headers.tera" as headers %}
2+
{% import "nav.tera" as nav %}
3+
{% import "footer.tera" as footer %}
14
<!DOCTYPE html>
25
<html lang="en">
36
<head>
47
<meta charset="utf-8">
5-
<title>{{ title }}</title>
8+
<title>{{ title | escape_hbs }}</title>
69
<meta name="viewport" content="width=device-width,initial-scale=1.0">
710
<meta name="description" content="Empowering everyone to build reliable and efficient software.">
8-
{{> headers }}
11+
{{ headers::headers(root=root, title=title, blog=blog) | indent(prefix=" ", blank=true) }}
912
</head>
1013
<body>
11-
{{> nav }}
12-
{{~> page}}
13-
{{> footer }}
14+
{{ nav::nav(root=root, blog=blog) | indent(prefix=" ", blank=true) }}
15+
{%- block page %}{% endblock page %}
16+
{{ footer::footer(root=root) | indent(prefix=" ", blank=true) }}
1417
</body>
1518
</html>

templates/nav.tera

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% macro nav(root, blog) -%}
12
<nav class="flex flex-row justify-center justify-end-l items-center flex-wrap ph2 pl3-ns pr4-ns">
23
<div class="brand flex-auto w-100 w-auto-l self-start tc tl-l">
34
<a href="{{root}}{{blog.prefix}}">
@@ -23,3 +24,4 @@
2324
<script src="{{root}}scripts/theme-switch-post.js"></script>
2425
</ul>
2526
</nav>
27+
{% endmacro %}

templates/post.tera

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
{{#*inline "page"}}
2-
<section id="{{post.title}}" class="white">
1+
{% extends "layout.tera" %}
2+
{% block page %}
3+
<section id="{{post.title | escape_hbs}}" class="white">
34
<div class="w-100 mw-none ph3 mw8-m mw8-l center f3">
45
<header>
5-
<h2>{{ post.title }}</h2>
6+
<h2>{{ post.title | escape_hbs }}</h2>
67
<div class="highlight mt2 mb3"></div>
78
</header>
89

9-
<div class="publish-date-author">{{month_name post.month}} {{post.day}}, {{post.year}} &middot; {{post.author}}
10-
{{#if post.has_team}} on behalf of <a href="{{post.team_url}}">{{post.team}}</a> {{/if}}
10+
<div class="publish-date-author">{{post.month | month_name}} {{post.day}}, {{post.year}} &middot; {{post.author | escape_hbs}}
11+
{% if post.has_team %} on behalf of <a href="{{post.team_url}}">{{post.team}}</a> {% endif %}
1112
</div>
1213

1314
<div class="post">
14-
{{{ post.contents }}}
15+
{{ post.contents }}
1516
</div>
1617
</div>
1718
</section>
18-
{{/inline}}
19-
{{~> layout~}}
19+
{%- endblock page %}

0 commit comments

Comments
 (0)