Skip to content

Commit 68a92fc

Browse files
authored
Merge branch 'master' into pr-dyn-compat
2 parents c02b251 + b856eb8 commit 68a92fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+5025
-3578
lines changed

.github/workflows/rust.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ on:
77
schedule:
88
- cron: "32 4 * * 5"
99

10-
concurrency:
11-
group: ${{ github.workflow }}-${{ github.ref }}
12-
cancel-in-progress: true
13-
1410
jobs:
1511
Test:
1612
strategy:
@@ -101,7 +97,7 @@ jobs:
10197
- uses: actions/checkout@v4
10298
- uses: dtolnay/rust-toolchain@master
10399
with:
104-
toolchain: "1.71.1"
100+
toolchain: "1.80.0"
105101
- run: cargo check --lib -p rinja --all-features
106102

107103
Audit:
@@ -114,10 +110,16 @@ jobs:
114110
runs-on: ubuntu-latest
115111
steps:
116112
- uses: actions/checkout@v4
117-
- uses: taiki-e/install-action@v2
118-
with:
119-
tool: mdbook
120-
- run: mdbook build book
113+
- name: Generate "book/theme/index.hbs" as "skeleton" of the generated pages.
114+
run: ./update-theme.py
115+
working-directory: book
116+
- name: Install mdbook
117+
run: |
118+
mkdir -p $HOME/bin
119+
curl --location --silent --show-error --fail https://github.com/cargo-bins/cargo-quickinstall/releases/download/mdbook-0.4.40/mdbook-0.4.40-x86_64-unknown-linux-gnu.tar.gz | tar -xzvvf - -C $HOME/bin
120+
- name: Convert the book to HTML
121+
run: $HOME/bin/mdbook build
122+
working-directory: book
121123

122124
DevSkim:
123125
name: DevSkim
@@ -175,11 +177,42 @@ jobs:
175177
components: rust-src
176178
- run: curl --location --silent --show-error --fail https://github.com/cargo-bins/cargo-quickinstall/releases/download/cargo-fuzz-0.12.0/cargo-fuzz-0.12.0-x86_64-unknown-linux-gnu.tar.gz | tar -xzvvf - -C $HOME/.cargo/bin
177179
- uses: Swatinem/rust-cache@v2
178-
- run: cargo fuzz run ${{ matrix.fuzz_target }} --jobs 4 -- -max_total_time=90
180+
- run: cargo fuzz run ${{ matrix.fuzz_target }} --jobs 4 -- -max_total_time=120
179181
working-directory: fuzzing
180182
env:
181183
RUSTFLAGS: '-Ctarget-feature=-crt-static'
182184

185+
Cluster-Fuzz:
186+
runs-on: ubuntu-latest
187+
permissions:
188+
security-events: write
189+
steps:
190+
- name: Build Fuzzers
191+
id: build
192+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
193+
with:
194+
oss-fuzz-project-name: rinja
195+
language: rust
196+
- name: Run Fuzzers
197+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
198+
with:
199+
oss-fuzz-project-name: rinja
200+
language: rust
201+
fuzz-seconds: 600
202+
output-sarif: true
203+
- name: Upload Crash
204+
uses: actions/upload-artifact@v4
205+
if: failure() && steps.build.outcome == 'success'
206+
with:
207+
name: artifacts
208+
path: ./out/artifacts
209+
- name: Upload Sarif
210+
if: always() && steps.build.outcome == 'success'
211+
uses: github/codeql-action/upload-sarif@v3
212+
with:
213+
sarif_file: cifuzz-sarif/results.sarif
214+
checkout_path: cifuzz-sarif
215+
183216
Typos:
184217
runs-on: ubuntu-latest
185218
steps:

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
**Rinja** implements a template rendering engine based on [Jinja](https://jinja.palletsprojects.com/),
99
and generates type-safe Rust code from your templates at compile time
1010
based on a user-defined `struct` to hold the template's context.
11-
See below for an example. It is a fork of [Askama](https://crates.io/crates/askama).
11+
See below for an example. It is a fork of [Askama](https://crates.io/crates/askama), please have a look at our
12+
[blog post](https://blog.guillaume-gomez.fr/articles/2024-07-31+docs.rs+switching+jinja+template+framework+from+tera+to+rinja)
13+
highlighting differences between the two crates.
1214

1315
All feedback welcome! Feel free to file bugs, requests for documentation and
1416
any other feedback to the [issue tracker][issues].

book/book.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ edition = "2021"
1111
[output.html]
1212
git-repository-url = "https://github.com/rinja-rs/rinja/tree/master/book"
1313
edit-url-template = "https://github.com/rinja-rs/rinja/tree/master/book/{path}"
14+
additional-css = ["theme/pagetoc.css"]
15+
additional-js = ["theme/pagetoc.js"]

book/src/configuration.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ The following keys can currently be used to customize template syntax:
108108
Values must be at least two characters long.
109109
If a key is omitted, the value from the default syntax is used.
110110

111+
## Escapers
112+
111113
Here is an example of a custom escaper:
112114

113115
```toml
@@ -118,10 +120,35 @@ extensions = ["tex"]
118120

119121
An escaper block consists of the attributes `path` and `extensions`. `path`
120122
contains a Rust identifier that must be in scope for templates using this
121-
escaper. `extensions` defines a list of file extensions that will trigger
123+
escaper. This type must implement the [`Escaper`]
124+
trait.
125+
126+
`extensions` defines a list of file extensions that will trigger
122127
the use of that escaper. Extensions are matched in order, starting with the
123128
first escaper configured and ending with the default escapers for HTML
124129
(extensions `html`, `htm`, `xml`, `j2`, `jinja`, `jinja2`) and plain text
125130
(no escaping; `md`, `yml`, `none`, `txt`, and the empty string). Note that
126131
this means you can also define other escapers that match different extensions
127132
to the same escaper.
133+
134+
You can then use templates with this extension or use the
135+
[`escape`](https://docs.rs/rinja/latest/rinja/filters/fn.escape.html) filter with
136+
the name of your extension in your template:
137+
138+
```jinja
139+
{{ some_string|escape("tex") }}
140+
```
141+
142+
As an example, we want `.js` files to be treated like "txt" files. To do so:
143+
144+
```toml
145+
[[escaper]]
146+
path = "rinja::filters::Text"
147+
extensions = ["js"]
148+
```
149+
150+
[`Text`](https://docs.rs/rinja/latest/rinja/filters/struct.Text.html) implements the
151+
[`Escaper`] trait so since we don't need want any escaping on our `.js` files, we use
152+
it.
153+
154+
[`Escaper`]: https://docs.rs/rinja/latest/rinja/filters/trait.Escaper.html

0 commit comments

Comments
 (0)