Skip to content

Commit 3c4d920

Browse files
Merge pull request #6 from Kijewski/pr-rtd
Add versioned book on readthedocs.org
2 parents 28eeba0 + a0f6ce5 commit 3c4d920

File tree

6 files changed

+156
-46
lines changed

6 files changed

+156
-46
lines changed

book/book.toml

+7
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ language = "en"
44
multilingual = false
55
src = "src"
66
title = "Rinja"
7+
8+
[rust]
9+
edition = "2021"
10+
11+
[output.html]
12+
git-repository-url = "https://github.com/rinja-rs/rinja/tree/master/book"
13+
edit-url-template = "https://github.com/rinja-rs/rinja/tree/master/book/{path}"

book/src/debugging.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The resulting output will be printed to `stderr` during the compilation process.
2020

2121
The parse tree looks like this for the example template:
2222

23-
```
23+
```rust
2424
[Lit("", "Hello,", " "), Expr(WS(false, false), Var("name")),
2525
Lit("", "!", "\n")]
2626
```

book/src/filters.md

+44-44
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ Enable it with Cargo features (see below for more information).
5656

5757
Returns the absolute value.
5858

59-
```
59+
```jinja
6060
{{ -2|abs }}
6161
```
6262

6363
Output:
6464

65-
```
65+
```text
6666
2
6767
```
6868

@@ -71,14 +71,14 @@ Output:
7171

7272
Creates a reference to the given argument.
7373

74-
```
74+
```jinja
7575
{{ "a"|as_ref }}
7676
{{ self.x|as_ref }}
7777
```
7878

7979
will become:
8080

81-
```
81+
```rust
8282
&"a"
8383
&self.x
8484
```
@@ -88,13 +88,13 @@ will become:
8888

8989
Capitalize a value. The first character will be uppercase, all others lowercase:
9090

91-
```
91+
```jinja
9292
{{ "hello"|capitalize }}
9393
```
9494

9595
Output:
9696

97-
```
97+
```text
9898
Hello
9999
```
100100

@@ -103,12 +103,12 @@ Hello
103103

104104
Centers the value in a field of a given width:
105105

106-
```
106+
```jinja
107107
-{{ "a"|center(5) }}-
108108
```
109109

110110
Output:
111-
```
111+
```text
112112
- a -
113113
```
114114

@@ -117,15 +117,15 @@ Output:
117117

118118
Dereferences the given argument.
119119

120-
```
120+
```jinja
121121
{% let s = String::from("a")|as_ref %}
122122
{% if s|deref == String::from("b") %}
123123
{% endif %}
124124
```
125125

126126
will become:
127127

128-
```
128+
```rust
129129
let s = &String::from("a");
130130
if *s == String::from("b") {}
131131
```
@@ -135,13 +135,13 @@ if *s == String::from("b") {}
135135

136136
Escapes HTML characters in strings:
137137

138-
```
138+
```jinja
139139
{{ "Escape <>&"|e }}
140140
```
141141

142142
Output:
143143

144-
```
144+
```html
145145
Escape &lt;&gt;&amp;
146146
```
147147

@@ -175,12 +175,12 @@ Escape &lt;&gt;&amp;
175175

176176
Returns adequate string representation (in KB, ..) of number of bytes:
177177

178-
```
178+
```jinja
179179
{{ 1000|filesizeformat }}
180180
```
181181

182182
Output:
183-
```
183+
```text
184184
1 KB
185185
```
186186

@@ -195,14 +195,14 @@ Rust). The two arguments are passed through to [`format!()`] by
195195
the Rinja code generator, but the order is swapped to support filter
196196
composition.
197197

198-
```text
198+
```jinja
199199
{{ value|fmt("{:?}") }}
200200
```
201201

202202
As an example, this allows filters to be composed like the following.
203203
Which is not possible using the `format` filter.
204204

205-
```text
205+
```jinja
206206
{{ value|capitalize|fmt("{:?}") }}
207207
```
208208

@@ -215,7 +215,7 @@ The first argument to this filter must be a string literal (as in normal Rust).
215215

216216
All arguments are passed through to [`format!()`] by the Rinja code generator.
217217

218-
```
218+
```jinja
219219
{{ "{:?}"|format(var) }}
220220
```
221221

@@ -226,13 +226,13 @@ All arguments are passed through to [`format!()`] by the Rinja code generator.
226226

227227
Indent newlines with width spaces.
228228

229-
```
229+
```jinja
230230
{{ "hello\nfoo\nbar"|indent(4) }}
231231
```
232232

233233
Output:
234234

235-
```
235+
```text
236236
hello
237237
foo
238238
bar
@@ -243,17 +243,17 @@ hello
243243

244244
Joins iterable into a string separated by provided argument.
245245

246-
```
246+
```rust
247247
array = &["foo", "bar", "bazz"]
248248
```
249249

250-
```
250+
```jinja
251251
{{ array|join(", ") }}
252252
```
253253

254254
Output:
255255

256-
```
256+
```text
257257
foo, bar, bazz
258258
```
259259

@@ -264,13 +264,13 @@ Replaces line breaks in plain text with appropriate HTML.
264264

265265
A single newline becomes an HTML line break `<br>` and a new line followed by a blank line becomes a paragraph break `<p>`.
266266

267-
```
267+
```jinja
268268
{{ "hello\nworld\n\nfrom\nrinja"|linebreaks }}
269269
```
270270

271271
Output:
272272

273-
```
273+
```html
274274
<p>hello<br />world</p><p>from<br />rinja</p>
275275
```
276276

@@ -279,13 +279,13 @@ Output:
279279

280280
Converts all newlines in a piece of plain text to HTML line breaks.
281281

282-
```
282+
```jinja
283283
{{ "hello\nworld\n\nfrom\nrinja"|linebreaks }}
284284
```
285285

286286
Output:
287287

288-
```
288+
```html
289289
hello<br />world<br /><br />from<br />rinja
290290
```
291291

@@ -298,13 +298,13 @@ Consecutive double line breaks will be reduced down to a single paragraph break.
298298

299299
This is useful in contexts where changing single line breaks to line break tags would interfere with other HTML elements, such as lists and nested `<div>` tags.
300300

301-
```
301+
```jinja
302302
{{ "hello\nworld\n\nfrom\n\n\n\nrinja"|paragraphbreaks }}
303303
```
304304

305305
Output:
306306

307-
```
307+
```html
308308
<p>hello\nworld</p><p>from</p><p>rinja</p>
309309
```
310310

@@ -313,13 +313,13 @@ Output:
313313

314314
Converts to lowercase.
315315

316-
```
316+
```jinja
317317
{{ "HELLO"|lower }}
318318
```
319319

320320
Output:
321321

322-
```
322+
```text
323323
hello
324324
```
325325

@@ -344,13 +344,13 @@ Output:
344344
Return a title cased version of the value. Words will start with uppercase letters, all
345345
remaining characters are lowercase.
346346

347-
```
347+
```jinja
348348
{{ "hello WORLD"|title }}
349349
```
350350

351351
Output:
352352

353-
```
353+
```text
354354
Hello World
355355
```
356356

@@ -359,13 +359,13 @@ Hello World
359359

360360
Strip leading and trailing whitespace.
361361

362-
```
362+
```jinja
363363
{{ " hello "|trim }}
364364
```
365365

366366
Output:
367367

368-
```
368+
```text
369369
hello
370370
```
371371

@@ -375,13 +375,13 @@ hello
375375
Limit string length, appends '...' if truncated.
376376

377377

378-
```
378+
```jinja
379379
{{ "hello"|truncate(2) }}
380380
```
381381

382382
Output:
383383

384-
```
384+
```text
385385
he...
386386
```
387387

@@ -390,13 +390,13 @@ he...
390390

391391
Converts to uppercase.
392392

393-
```
393+
```jinja
394394
{{ "hello"|upper }}
395395
```
396396

397397
Output:
398398

399-
```
399+
```text
400400
HELLO
401401
```
402402

@@ -405,13 +405,13 @@ HELLO
405405

406406
Percent encodes the string. Replaces reserved characters with the % escape character followed by a byte value as two hexadecimal digits.
407407

408-
```
408+
```text
409409
hello?world
410410
```
411411

412412
Output:
413413

414-
```
414+
```text
415415
hello%3Fworld
416416
```
417417

@@ -420,13 +420,13 @@ hello%3Fworld
420420

421421
Count the words in that string.
422422

423-
```
423+
```jinja
424424
{{ "rinja is sort of cool"|wordcount }}
425425
```
426426

427427
Output:
428428

429-
```
429+
```text
430430
5
431431
```
432432

@@ -436,7 +436,7 @@ Output:
436436
The following filters can be enabled by requesting the respective feature in the Cargo.toml
437437
[dependencies section](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html), e.g.
438438

439-
```
439+
```toml
440440
[dependencies]
441441
rinja = { version = "0.11.2", features = "serde-json" }
442442
```
@@ -454,7 +454,7 @@ In HTML attributes, you can either use it in quotation marks `"{{data|json}}"` a
454454
or in apostrophes with the (optional) safe filter `'{{data|json|safe}}'`.
455455
In HTML texts the output of e.g. `<pre>{{data|json|safe}}</pre>` is safe, too.
456456

457-
```
457+
```jinja
458458
Good: <li data-extra="{{data|json}}">…</li>
459459
Good: <li data-extra='{{data|json|safe}}'>…</li>
460460
Good: <pre>{{data|json|safe}}</pre>

book/src/getting_started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rinja = "0.12.1"
1010
Now create a directory called `templates` in your crate root.
1111
In it, create a file called `hello.html`, containing the following:
1212

13-
```
13+
```jinja
1414
Hello, {{ name }}!
1515
```
1616

book/theme/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

0 commit comments

Comments
 (0)