Skip to content

Commit 79fd51d

Browse files
authored
Rollup merge of #108805 - GuillaumeGomez:update-askama, r=notriddle
Update askama to 0.12 and improve whitespace control `askama` 0.12 was just released, and it adds the possibility to have "whitespace suppression" enabled by default in the configuration so I switched to it. r? ``@notriddle``
2 parents 4dc48db + 511d262 commit 79fd51d

File tree

6 files changed

+226
-210
lines changed

6 files changed

+226
-210
lines changed

Cargo.lock

+37-23
Original file line numberDiff line numberDiff line change
@@ -132,47 +132,36 @@ checksum = "5a2f58b0bb10c380af2b26e57212856b8c9a59e0925b4c20f4a174a49734eaf7"
132132

133133
[[package]]
134134
name = "askama"
135-
version = "0.11.0"
135+
version = "0.12.0"
136136
source = "registry+https://github.com/rust-lang/crates.io-index"
137-
checksum = "4d8f355701c672c2ba3d718acbd213f740beea577cc4eae66accdffe15be1882"
137+
checksum = "47cbc3cf73fa8d9833727bbee4835ba5c421a0d65b72daf9a7b5d0e0f9cfb57e"
138138
dependencies = [
139139
"askama_derive",
140140
"askama_escape",
141-
"askama_shared",
142141
]
143142

144143
[[package]]
145144
name = "askama_derive"
146-
version = "0.11.0"
147-
source = "registry+https://github.com/rust-lang/crates.io-index"
148-
checksum = "84704cab5b7ae0fd3a9f78ee5eb7b27f3749df445f04623db6633459ae283267"
149-
dependencies = [
150-
"askama_shared",
151-
"proc-macro2",
152-
"syn",
153-
]
154-
155-
[[package]]
156-
name = "askama_escape"
157-
version = "0.10.2"
158-
source = "registry+https://github.com/rust-lang/crates.io-index"
159-
checksum = "9a1bb320f97e6edf9f756bf015900038e43c7700e059688e5724a928c8f3b8d5"
160-
161-
[[package]]
162-
name = "askama_shared"
163145
version = "0.12.0"
164146
source = "registry+https://github.com/rust-lang/crates.io-index"
165-
checksum = "dae03eebba55a2697a376e58b573a29fe36893157173ac8df312ad85f3c0e012"
147+
checksum = "e80b5ad1afe82872b7aa3e9de9b206ecb85584aa324f0f60fa4c903ce935936b"
166148
dependencies = [
167-
"askama_escape",
149+
"basic-toml",
150+
"mime",
151+
"mime_guess",
168152
"nom",
169153
"proc-macro2",
170154
"quote",
171155
"serde",
172156
"syn",
173-
"toml 0.5.7",
174157
]
175158

159+
[[package]]
160+
name = "askama_escape"
161+
version = "0.10.3"
162+
source = "registry+https://github.com/rust-lang/crates.io-index"
163+
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
164+
176165
[[package]]
177166
name = "atty"
178167
version = "0.2.14"
@@ -223,6 +212,15 @@ version = "1.5.3"
223212
source = "registry+https://github.com/rust-lang/crates.io-index"
224213
checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf"
225214

215+
[[package]]
216+
name = "basic-toml"
217+
version = "0.1.2"
218+
source = "registry+https://github.com/rust-lang/crates.io-index"
219+
checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1"
220+
dependencies = [
221+
"serde",
222+
]
223+
226224
[[package]]
227225
name = "bitflags"
228226
version = "1.3.2"
@@ -2614,6 +2612,22 @@ dependencies = [
26142612
"autocfg",
26152613
]
26162614

2615+
[[package]]
2616+
name = "mime"
2617+
version = "0.3.16"
2618+
source = "registry+https://github.com/rust-lang/crates.io-index"
2619+
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
2620+
2621+
[[package]]
2622+
name = "mime_guess"
2623+
version = "2.0.4"
2624+
source = "registry+https://github.com/rust-lang/crates.io-index"
2625+
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
2626+
dependencies = [
2627+
"mime",
2628+
"unicase",
2629+
]
2630+
26172631
[[package]]
26182632
name = "minifier"
26192633
version = "0.2.2"

src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ path = "lib.rs"
88

99
[dependencies]
1010
arrayvec = { version = "0.7", default-features = false }
11-
askama = { version = "0.11", default-features = false, features = ["config"] }
11+
askama = { version = "0.12", default-features = false, features = ["config"] }
1212
itertools = "0.10.1"
1313
minifier = "0.2.2"
1414
once_cell = "1.10.0"

src/librustdoc/askama.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[general]
22
dirs = ["html/templates"]
3+
whitespace = "suppress"

src/librustdoc/html/templates/STYLE.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,29 @@ similar to [Jinja2](jinjadoc) and [Django](djangodoc) templates, and also to [As
1010

1111
We want our rendered output to have as little unnecessary whitespace as
1212
possible, so that pages load quickly. To achieve that we use Tera's
13-
[whitespace control] features. At the end of most lines, we put an empty comment
14-
tag with the whitespace control characters: `{#- -#}`. This causes all
15-
whitespace between the end of the line and the beginning of the next, including
16-
indentation, to be omitted on render. Sometimes we want to preserve a single
17-
space. In those cases we put the space at the end of the line, followed by
18-
`{# -#}`, which is a directive to remove following whitespace but not preceding.
19-
We also use the whitespace control characters in most instances of tags with
20-
control flow, for example `{%- if foo -%}`.
13+
[whitespace control] features. By default, whitespace characters are removed
14+
around jinja tags (`{% %}` for example). At the end of most lines, we put an
15+
empty comment tag: `{# #}`. This causes all whitespace between the end of the
16+
line and the beginning of the next, including indentation, to be omitted on
17+
render. Sometimes we want to preserve a single space. In those cases we put the
18+
space at the end of the line, followed by `{#+ #}`, which is a directive to
19+
remove following whitespace but not preceding. We also use the whitespace
20+
control characters in most instances of tags with control flow, for example
21+
`{% if foo %}`.
2122

2223
[whitespace control]: https://tera.netlify.app/docs/#whitespace-control
2324

2425
We want our templates to be readable, so we use indentation and newlines
25-
liberally. We indent by four spaces after opening an HTML tag _or_ a Tera
26+
liberally. We indent by four spaces after opening an HTML tag _or_ a Jinja
2627
tag. In most cases an HTML tag should be followed by a newline, but if the
2728
tag has simple contents and fits with its close tag on a single line, the
2829
contents don't necessarily need a new line.
2930

30-
Tera templates support quite sophisticated control flow. To keep our templates
31+
Askama templates support quite sophisticated control flow. To keep our templates
3132
simple and understandable, we use only a subset: `if` and `for`. In particular
32-
we avoid [assignments in the template logic](assignments) and [Tera
33+
we avoid [assignments in the template logic](assignments) and [Askama
3334
macros](macros). This also may make things easier if we switch to a different
3435
Jinja-style template system, like Askama, in the future.
3536

36-
[assignments]: https://tera.netlify.app/docs/#assignments
37-
[macros]: https://tera.netlify.app/docs/#macros
37+
[assignments]: https://djc.github.io/askama/template_syntax.html#assignments
38+
[macros]: https://djc.github.io/askama/template_syntax.html#macros

0 commit comments

Comments
 (0)