Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename rinja into askama #353

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
Rustfmt:
runs-on: ubuntu-latest
steps:
# No need to test `rinja_derive_standalone`. It has same the `src` folder as `rinja_derive`.
# No need to test `askama_derive_standalone`. It has same the `src` folder as `askama_derive`.
# No need to run the checks in parallel. They are fast enough.
# No need for caching. No code is compiled at all.
- uses: actions/checkout@v4
Expand All @@ -27,7 +27,7 @@ jobs:
set -eu
for PKG in \
bench-build examples/actix-web-app examples/axum-app examples/poem-app examples/rocket-app examples/salvo-app examples/warp-app fuzzing \
rinja rinja_derive rinja_derive_standalone rinja_parser \
askama askama_derive askama_derive_standalone askama_parser \
testing testing-alloc testing-no-std testing-renamed
do
cd "$PKG"
Expand All @@ -39,7 +39,7 @@ jobs:
Docs:
strategy:
matrix:
package: [rinja, rinja_derive, rinja_parser]
package: [askama, askama_derive, askama_parser]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
set -eu
for PKG in \
bench-build examples/actix-web-app examples/axum-app examples/poem-app examples/rocket-app examples/salvo-app examples/warp-app fuzzing \
rinja rinja_derive rinja_derive_standalone rinja_parser \
askama askama_derive askama_derive_standalone askama_parser \
testing testing-alloc testing-no-std testing-renamed
do
cd "$PKG"
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
matrix:
package: [
bench-build, examples/actix-web-app, examples/axum-app, examples/poem-app, examples/rocket-app, examples/salvo-app, examples/warp-app, fuzzing,
rinja, rinja_derive, rinja_derive_standalone, rinja_parser,
askama, askama_derive, askama_derive_standalone, askama_parser,
testing, testing-alloc, testing-no-std, testing-renamed,
]
runs-on: ubuntu-latest
Expand All @@ -185,7 +185,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.81.0"
- run: cargo check --lib -p rinja --all-features
- run: cargo check --lib -p askama --all-features

####################################################################################################
# STEP 2: SLOW
Expand Down Expand Up @@ -218,34 +218,34 @@ jobs:
env:
RUSTFLAGS: '-Ctarget-feature=-crt-static'

Cluster-Fuzz:
needs: ["Test", "Package", "MSRV"]
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: rinja
language: rust
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: rinja
language: rust
fuzz-seconds: 600
output-sarif: true
- name: Upload Crash
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
- name: Upload Sarif
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif
# Cluster-Fuzz:
# needs: ["Test", "Package", "MSRV"]
# runs-on: ubuntu-latest
# permissions:
# security-events: write
# steps:
# - name: Build Fuzzers
# id: build
# uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
# with:
# oss-fuzz-project-name: askama
# language: rust
# - name: Run Fuzzers
# uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
# with:
# oss-fuzz-project-name: askama
# language: rust
# fuzz-seconds: 600
# output-sarif: true
# - name: Upload Crash
# uses: actions/upload-artifact@v4
# if: failure() && steps.build.outcome == 'success'
# with:
# name: artifacts
# path: ./out/artifacts
# - name: Upload Sarif
# if: always() && steps.build.outcome == 'success'
# uses: github/codeql-action/upload-sarif@v3
# with:
# sarif_file: cifuzz-sarif/results.sarif
# checkout_path: cifuzz-sarif
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[workspace]
members = [
"rinja",
"rinja_derive",
"rinja_parser",
"askama",
"askama_derive",
"askama_parser",
"testing",
"testing-alloc",
"testing-no-std",
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# rinja
# askama

[![Crates.io](https://img.shields.io/crates/v/rinja?logo=rust&style=flat-square&logoColor=white "Crates.io")](https://crates.io/crates/rinja)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/rinja-rs/rinja/rust.yml?branch=master&logo=github&style=flat-square&logoColor=white "GitHub Workflow Status")](https://github.com/rinja-rs/rinja/actions/workflows/rust.yml)
[![Book](https://img.shields.io/readthedocs/rinja?label=book&logo=readthedocs&style=flat-square&logoColor=white "Book")](https://rinja.readthedocs.io/)
[![docs.rs](https://img.shields.io/docsrs/rinja?logo=docsdotrs&style=flat-square&logoColor=white "docs.rs")](https://docs.rs/rinja/)
[![Crates.io](https://img.shields.io/crates/v/askama?logo=rust&style=flat-square&logoColor=white "Crates.io")](https://crates.io/crates/askama)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/askama-rs/askama/rust.yml?branch=master&logo=github&style=flat-square&logoColor=white "GitHub Workflow Status")](https://github.com/askama-rs/askama/actions/workflows/rust.yml)
[![Book](https://img.shields.io/readthedocs/askama?label=book&logo=readthedocs&style=flat-square&logoColor=white "Book")](https://askama.readthedocs.io/)
[![docs.rs](https://img.shields.io/docsrs/askama?logo=docsdotrs&style=flat-square&logoColor=white "docs.rs")](https://docs.rs/askama/)

**Rinja** implements a template rendering engine based on [Jinja](https://jinja.palletsprojects.com/),
**Askama** implements a template rendering engine based on [Jinja](https://jinja.palletsprojects.com/),
and generates type-safe Rust code from your templates at compile time
based on a user-defined `struct` to hold the template's context.
See below for an example. It is a fork of [Askama](https://crates.io/crates/askama), please have a look at our
[blog post](https://blog.guillaume-gomez.fr/articles/2024-07-31+docs.rs+switching+jinja+template+framework+from+tera+to+rinja)
highlighting differences between the two crates.

At some point, **Askama** got forked into **Rinja** (explained [here](https://blog.guillaume-gomez.fr/articles/2024-07-31+docs.rs+switching+jinja+template+framework+from+tera+to+rinja))
before getting merged back into **Askama**.

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

You can find the documentation about our syntax, features, configuration in our book:
[rinja.readthedocs.io](https://rinja.readthedocs.io/).
[askama.readthedocs.io](https://askama.readthedocs.io/).

Have a look at our [*Rinja Playground*](https://rinja-rs.github.io/play-rinja/),
if you want to try out rinja's code generation online.
Have a look at our [*Askama Playground*](https://askama-rs.github.io/play-askama/),
if you want to try out askama's code generation online.

### Feature highlights

Expand All @@ -41,16 +41,16 @@ if you want to try out rinja's code generation online.
* Opt-out HTML escaping
* Syntax customization

[issues]: https://github.com/rinja-rs/rinja/issues
[issues]: https://github.com/askama-rs/askama/issues


How to get started
------------------

First, add the rinja dependency to your crate's `Cargo.toml`:
First, add the askama dependency to your crate's `Cargo.toml`:

```sh
cargo add rinja
cargo add askama
```

Now create a directory called `templates` in your crate root.
Expand All @@ -63,7 +63,7 @@ Hello, {{ name }}!
In any Rust file inside your crate, add the following:

```rust
use rinja::Template; // bring trait in scope
use askama::Template; // bring trait in scope

#[derive(Template)] // this will generate the code...
#[template(path = "hello.html")] // using the template in this path, relative
Expand Down
4 changes: 2 additions & 2 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ extend-exclude = [
"fuzzing/fuzz/artifacts/",
"fuzzing/fuzz/corpus/",
"target/",
"rinja_parser/tests/*.txt",
"askama_parser/tests/*.txt",
"testing/templates/fuzzed-*",
# filler texts
"rinja/benches/strings.inc",
"askama/benches/strings.inc",
# too many false positives
"testing/tests/gen_ws_tests.py",
]
Expand Down
File renamed without changes.
28 changes: 14 additions & 14 deletions rinja/Cargo.toml → askama/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "rinja"
name = "askama"
version = "0.3.5"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version = "0.3.5"
version = "0.13.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to do that in another PR. We'll need to update the version before the release in any case.

description = "Type-safe, compiled Jinja-like templates for Rust"
keywords = ["markup", "template", "jinja2", "html"]
categories = ["template-engine"]
homepage = "https://rinja.readthedocs.io/"
repository = "https://github.com/rinja-rs/rinja"
homepage = "https://askama.readthedocs.io/"
repository = "https://github.com/askama-rs/askama"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.81"
Expand All @@ -27,7 +27,7 @@ harness = false
itoa = "1.0.11"

# needed by feature "derive"
rinja_derive = { version = "=0.3.5", path = "../rinja_derive", default-features = false, optional = true }
askama_derive = { version = "=0.3.5", path = "../askama_derive", default-features = false, optional = true }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
askama_derive = { version = "=0.3.5", path = "../askama_derive", default-features = false, optional = true }
askama_derive = { version = "=0.13.0", path = "../askama_derive", default-features = false, optional = true }


# needed by feature "serde_json"
serde = { version = "1.0", optional = true, default-features = false }
Expand All @@ -44,25 +44,25 @@ criterion = "0.5"
maintenance = { status = "actively-developed" }

[features]
default = ["config", "derive", "std", "urlencode", "rinja_derive?/default"]
full = ["default", "blocks", "code-in-doc", "serde_json", "rinja_derive?/full"]
default = ["config", "derive", "std", "urlencode", "askama_derive?/default"]
full = ["default", "blocks", "code-in-doc", "serde_json", "askama_derive?/full"]

alloc = [
"rinja_derive?/alloc",
"askama_derive?/alloc",
"serde?/alloc",
"serde_json?/alloc",
"percent-encoding?/alloc",
]
blocks = ["rinja_derive?/blocks"]
code-in-doc = ["rinja_derive?/code-in-doc"]
config = ["rinja_derive?/config"]
derive = ["rinja_derive"]
serde_json = ["std", "rinja_derive?/serde_json", "dep:serde", "dep:serde_json"]
blocks = ["askama_derive?/blocks"]
code-in-doc = ["askama_derive?/code-in-doc"]
config = ["askama_derive?/config"]
derive = ["askama_derive"]
serde_json = ["std", "askama_derive?/serde_json", "dep:serde", "dep:serde_json"]
std = [
"alloc",
"rinja_derive?/std",
"askama_derive?/std",
"serde?/std",
"serde_json?/std",
"percent-encoding?/std",
]
urlencode = ["rinja_derive?/urlencode", "dep:percent-encoding"]
urlencode = ["askama_derive?/urlencode", "dep:percent-encoding"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion rinja/benches/escape.rs → askama/benches/escape.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use askama::filters::{Html, escape};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use rinja::filters::{Html, escape};

criterion_main!(benches);
criterion_group!(benches, functions);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion rinja/benches/to-json.rs → askama/benches/to-json.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use askama::Template;
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use rinja::Template;

criterion_main!(benches);
criterion_group!(benches, functions);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions rinja/src/error.rs → askama/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::io;
/// The [`Result`](std::result::Result) type with [`Error`] as default error type
pub type Result<I, E = Error> = core::result::Result<I, E>;

/// rinja's error type
/// askama's error type
///
/// Used as error value for e.g. [`Template::render()`][crate::Template::render()]
/// and custom filters.
Expand Down Expand Up @@ -159,7 +159,7 @@ fn error_from_stderror(err: Box<dyn StdError + Send + Sync>, unwraps: usize) ->
Ok(err) => error_from_io_error(*err, unwraps),
Err(_) => Error::Fmt, // unreachable
},
ErrorKind::Rinja => match err.downcast() {
ErrorKind::Askama => match err.downcast() {
Ok(err) => *err,
Err(_) => Error::Fmt, // unreachable
},
Expand All @@ -179,7 +179,7 @@ fn error_from_io_error(err: io::Error, unwraps: usize) -> Error {
};
match ErrorKind::inspect(inner) {
ErrorKind::Fmt => Error::Fmt,
ErrorKind::Rinja => match err.downcast() {
ErrorKind::Askama => match err.downcast() {
Ok(err) => err,
Err(_) => Error::Fmt, // unreachable
},
Expand Down Expand Up @@ -207,7 +207,7 @@ enum ErrorKind {
Json,
#[cfg(feature = "std")]
Io,
Rinja,
Askama,
}

#[cfg(feature = "alloc")]
Expand All @@ -223,7 +223,7 @@ impl ErrorKind {
}

if err.is::<Error>() {
return ErrorKind::Rinja;
return ErrorKind::Askama;
}

#[cfg(feature = "serde_json")]
Expand Down Expand Up @@ -264,7 +264,7 @@ pub trait ResultConverter {
type Input;

/// Consume an interior mutable `self`, and turn it into a [`crate::Result`]
fn rinja_conv_result(self, result: Self::Input) -> Result<Self::Value, Error>;
fn askama_conv_result(self, result: Self::Input) -> Result<Self::Value, Error>;
}

/// Helper marker to be used with [`ResultConverter`]
Expand All @@ -288,7 +288,7 @@ where
type Input = Result<T, E>;

#[inline]
fn rinja_conv_result(self, result: Self::Input) -> Result<Self::Value, Error> {
fn askama_conv_result(self, result: Self::Input) -> Result<Self::Value, Error> {
result.map_err(Error::custom)
}
}
Expand All @@ -301,7 +301,7 @@ where
type Input = Result<T, E>;

#[inline]
fn rinja_conv_result(self, result: Self::Input) -> Result<Self::Value, Error> {
fn askama_conv_result(self, result: Self::Input) -> Result<Self::Value, Error> {
result.map_err(Into::into)
}
}
Loading
Loading