aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-28 22:49:04 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2020-01-29 09:25:59 +0100
commitff24eef1ff7dcf3849fd1e6d9efec0de2bc57005 (patch)
treedb3a606f7cf88b6a932484c799a441cab9dd7996
parent75f32d3967e4d13b86b0d720ebc808c6fd9caa05 (diff)
downloadaskama-ff24eef1ff7dcf3849fd1e6d9efec0de2bc57005.tar.gz
askama-ff24eef1ff7dcf3849fd1e6d9efec0de2bc57005.tar.bz2
askama-ff24eef1ff7dcf3849fd1e6d9efec0de2bc57005.zip
Move Iron integration into a separate askama_iron crate
Diffstat (limited to '')
-rw-r--r--.github/workflows/rust.yml18
-rw-r--r--Cargo.toml1
-rw-r--r--askama/Cargo.toml3
-rw-r--r--askama/src/lib.rs7
-rw-r--r--askama_derive/src/generator.rs8
-rw-r--r--askama_iron/Cargo.toml17
-rw-r--r--askama_iron/src/lib.rs3
-rw-r--r--askama_iron/templates/hello.html (renamed from testing/templates/hello.txt)0
-rw-r--r--askama_iron/templates/hello.txt1
-rw-r--r--askama_iron/tests/basic.rs (renamed from testing/tests/iron.rs)1
-rw-r--r--testing/Cargo.toml6
11 files changed, 37 insertions, 28 deletions
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index c8ae1ea..3c7fab9 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -34,7 +34,7 @@ jobs:
with:
command: test
- stable-integrations:
+ Actix-Web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@@ -44,10 +44,10 @@ jobs:
toolchain: stable
override: true
- run: |
- cd testing
- cargo test --features full
+ cargo test --package askama_actix --all-targets
+ cargo clippy --package askama_actix --all-targets -- -D warnings
- Actix-Web:
+ Gotham:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@@ -58,10 +58,10 @@ jobs:
override: true
components: clippy
- run: |
- cargo test --package askama_actix --all-targets
- cargo clippy --package askama_actix --all-targets -- -D warnings
+ cargo test --package askama_gotham --all-targets
+ cargo clippy --package askama_gotham --all-targets -- -D warnings
- Gotham:
+ Iron:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@@ -72,8 +72,8 @@ jobs:
override: true
components: clippy
- run: |
- cargo test --package askama_gotham --all-targets
- cargo clippy --package askama_gotham --all-targets -- -D warnings
+ cargo test --package askama_iron --all-targets
+ cargo clippy --package askama_iron --all-targets -- -D warnings
Rocket:
runs-on: ubuntu-latest
diff --git a/Cargo.toml b/Cargo.toml
index 07f1889..6ff87a4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,7 @@ members = [
"askama_gotham",
"askama_derive",
"askama_escape",
+ "askama_iron",
"askama_rocket",
"askama_shared",
"testing",
diff --git a/askama/Cargo.toml b/askama/Cargo.toml
index 78be3d4..a9749ba 100644
--- a/askama/Cargo.toml
+++ b/askama/Cargo.toml
@@ -24,7 +24,7 @@ humansize = ["askama_shared/humansize"]
serde-json = ["askama_shared/json"]
serde-yaml = ["askama_shared/yaml"]
num-traits = ["askama_shared/num-traits"]
-with-iron = ["iron", "askama_derive/iron"]
+with-iron = ["askama_derive/iron"]
with-rocket = ["askama_derive/rocket"]
with-actix-web = ["askama_derive/actix-web"]
with-gotham = ["askama_derive/gotham"]
@@ -33,7 +33,6 @@ with-gotham = ["askama_derive/gotham"]
askama_derive = { version = "0.9.0", path = "../askama_derive" }
askama_escape = { version = "0.3.0", path = "../askama_escape" }
askama_shared = { version = "0.9.0", path = "../askama_shared", default-features = false }
-iron = { version = ">= 0.5, < 0.7", optional = true }
mime = { version = "0.3", optional = true }
mime_guess = { version = "2.0.0-alpha", optional = true }
diff --git a/askama/src/lib.rs b/askama/src/lib.rs
index f3a7a22..4e4611b 100644
--- a/askama/src/lib.rs
+++ b/askama/src/lib.rs
@@ -516,13 +516,6 @@ pub use crate::shared::helpers;
pub use crate::shared::{read_config_file, Error, MarkupDisplay, Result};
pub use askama_derive::*;
-#[cfg(feature = "with-iron")]
-pub mod iron {
- pub use iron::headers::ContentType;
- pub use iron::modifier::Modifier;
- pub use iron::response::Response;
-}
-
pub mod mime {
#[cfg(all(feature = "mime_guess", feature = "mime"))]
pub fn extension_to_mime_type(ext: &str) -> mime_guess::Mime {
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 949019b..9532057 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -191,12 +191,12 @@ impl<'a> Generator<'a> {
fn impl_modifier_response(&mut self, buf: &mut Buffer) {
self.write_header(
buf,
- "::askama::iron::Modifier<::askama::iron::Response>",
+ "::askama_iron::Modifier<::askama_iron::Response>",
None,
);
- buf.writeln("fn modify(self, res: &mut ::askama::iron::Response) {");
+ buf.writeln("fn modify(self, res: &mut ::askama_iron::Response) {");
buf.writeln(
- "res.body = Some(Box::new(::askama::Template::render(&self).unwrap().into_bytes()));",
+ "res.body = Some(Box::new(::askama_iron::Template::render(&self).unwrap().into_bytes()));",
);
let ext = self
@@ -206,7 +206,7 @@ impl<'a> Generator<'a> {
.map_or("", |s| s.to_str().unwrap_or(""));
match ext {
"html" | "htm" => {
- buf.writeln("::askama::iron::ContentType::html().0.modify(res);");
+ buf.writeln("::askama_iron::ContentType::html().0.modify(res);");
}
_ => (),
};
diff --git a/askama_iron/Cargo.toml b/askama_iron/Cargo.toml
new file mode 100644
index 0000000..35c585d
--- /dev/null
+++ b/askama_iron/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "askama_iron"
+version = "0.9.0"
+authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>"]
+description = "Iron integration for Askama templates"
+documentation = "https://docs.rs/askama"
+keywords = ["markup", "template", "jinja2", "html"]
+categories = ["template-engine"]
+homepage = "https://github.com/djc/askama"
+repository = "https://github.com/djc/askama"
+license = "MIT OR Apache-2.0"
+workspace = ".."
+edition = "2018"
+
+[dependencies]
+askama = { version = "0.9.0", path = "../askama", features = ["with-iron"] }
+iron = { version = ">= 0.5, < 0.7" }
diff --git a/askama_iron/src/lib.rs b/askama_iron/src/lib.rs
new file mode 100644
index 0000000..37e79cc
--- /dev/null
+++ b/askama_iron/src/lib.rs
@@ -0,0 +1,3 @@
+pub use askama::*;
+
+pub use iron::{headers::ContentType, modifier::Modifier, Response};
diff --git a/testing/templates/hello.txt b/askama_iron/templates/hello.html
index 8149be7..8149be7 100644
--- a/testing/templates/hello.txt
+++ b/askama_iron/templates/hello.html
diff --git a/askama_iron/templates/hello.txt b/askama_iron/templates/hello.txt
new file mode 100644
index 0000000..8149be7
--- /dev/null
+++ b/askama_iron/templates/hello.txt
@@ -0,0 +1 @@
+Hello, {{ name }}!
diff --git a/testing/tests/iron.rs b/askama_iron/tests/basic.rs
index f58a609..32ca839 100644
--- a/testing/tests/iron.rs
+++ b/askama_iron/tests/basic.rs
@@ -1,4 +1,3 @@
-#![cfg(feature = "iron")]
use askama::Template;
use iron::{status, Response};
diff --git a/testing/Cargo.toml b/testing/Cargo.toml
index 5517047..ff2b137 100644
--- a/testing/Cargo.toml
+++ b/testing/Cargo.toml
@@ -6,14 +6,10 @@ workspace = ".."
edition = "2018"
[features]
-default = []
-full = ["with-iron", "serde-json"]
-serde-json = ["serde_json", "askama/serde-json"]
-with-iron = ["iron", "askama/with-iron"]
+default = ["serde_json", "askama/serde-json"]
[dependencies]
askama = { path = "../askama", version = "*" }
-iron = { version = "0.6", optional = true }
serde_json = { version = "1.0", optional = true }
[dev-dependencies]