diff options
Diffstat (limited to '')
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | askama/Cargo.toml | 1 | ||||
-rw-r--r-- | askama/src/filters.rs | 8 | ||||
-rw-r--r-- | askama/src/lib.rs | 2 |
4 files changed, 18 insertions, 0 deletions
@@ -11,6 +11,7 @@ name = "askama" version = "0.1.0" dependencies = [ "askama_derive 0.1.0", + "htmlescape 0.3.1 (git+https://github.com/veddan/rust-htmlescape)", ] [[package]] @@ -23,6 +24,11 @@ dependencies = [ ] [[package]] +name = "htmlescape" +version = "0.3.1" +source = "git+https://github.com/veddan/rust-htmlescape#1699b539179798e705ad8464128492a0a0092876" + +[[package]] name = "nom" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -47,6 +53,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum htmlescape 0.3.1 (git+https://github.com/veddan/rust-htmlescape)" = "<none>" "checksum nom 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc564b2727f758993db55d4ffed0d84bbd7f387a66509516768c8f786bb0b10" "checksum quote 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6732e32663c9c271bfc7c1823486b471f18c47a2dbf87c066897b7b51afc83be" "checksum syn 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1a437f8b4353179418870f014113876cd4cd4f642e42dbc5ed4f328d5f808246" diff --git a/askama/Cargo.toml b/askama/Cargo.toml index b2e0fbe..7864818 100644 --- a/askama/Cargo.toml +++ b/askama/Cargo.toml @@ -6,3 +6,4 @@ workspace = ".." [dependencies] askama_derive = { path = "../askama_derive" } +htmlescape = { git = "https://github.com/veddan/rust-htmlescape" } diff --git a/askama/src/filters.rs b/askama/src/filters.rs new file mode 100644 index 0000000..08feed3 --- /dev/null +++ b/askama/src/filters.rs @@ -0,0 +1,8 @@ +extern crate htmlescape; + +use std::fmt; + +pub fn e(s: &fmt::Display) -> String { + let s = format!("{}", s); + htmlescape::encode_minimal(&s) +} diff --git a/askama/src/lib.rs b/askama/src/lib.rs index 2412b1f..f89683f 100644 --- a/askama/src/lib.rs +++ b/askama/src/lib.rs @@ -7,6 +7,8 @@ pub trait Template { fn render(&self) -> String; } +pub mod filters; + #[cfg(test)] mod tests { |