Skip to content
Merged
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
3 changes: 1 addition & 2 deletions askama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ maintenance = { status = "actively-developed" }

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

alloc = [
"askama_macros?/alloc",
"serde?/alloc",
"serde_json?/alloc",
"percent-encoding?/alloc",
]
blocks = ["askama_macros?/blocks"]
code-in-doc = ["askama_macros?/code-in-doc"]
config = ["askama_macros?/config"]
derive = ["dep:askama_macros", "dep:askama_macros"]
Expand Down
2 changes: 2 additions & 0 deletions askama/src/filters/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ impl<'a, T: HtmlSafe + ?Sized> AutoEscape for &AutoEscaper<'a, T, Html> {
/// use askama::{filters::MaybeSafe, Result, Values};
///
/// // Do not actually use this filter! It's an intentionally bad example.
/// #[askama::filter_fn]
/// pub fn backdoor<T: std::fmt::Display>(
/// s: T,
/// _: &dyn Values,
Expand Down Expand Up @@ -386,6 +387,7 @@ const _: () = {
/// use askama::{filters::Safe, Result, Values};
///
/// // Do not actually use this filter! It's an intentionally bad example.
/// #[askama::filter_fn]
/// pub fn strip_except_apos(s: impl ToString, _: &dyn Values) -> Result<Safe<String>> {
/// Ok(Safe(s
/// .to_string()
Expand Down
11 changes: 11 additions & 0 deletions askama/src/filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ pub use self::urlencode::{urlencode, urlencode_strict};

// MAX_LEN is maximum allowed length for filters.
const MAX_LEN: usize = 10_000;

/// Internal trait that is used by the `filter_fn` proc-macro to produce nicer error messages when
/// too many arguments were passed to a filter invocation.
#[doc(hidden)]
#[diagnostic::on_unimplemented(
message = "Argument at position {IDX} is invalid on filter {Self}. Too many arguments supplied?",
label = "Filter function"
)]
pub trait ValidArgIdx<const IDX: usize> {
const VALID: bool = true;
}
2 changes: 2 additions & 0 deletions askama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ use std::io;

#[cfg(feature = "derive")]
pub use askama_macros::Template;
#[cfg(feature = "derive")]
pub use askama_macros::filter_fn;

pub use crate::error::{Error, Result};
pub use crate::helpers::PrimitiveType;
Expand Down
5 changes: 1 addition & 4 deletions askama_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,18 @@ memchr = "2"
proc-macro2 = { version = "1", default-features = false }
quote = { version = "1", default-features = false }
rustc-hash = "2.0.0"
syn = { version = "2.0.3", default-features = false, features = ["clone-impls", "derive", "parsing", "printing"] }
syn = { version = "2.0.3", default-features = false, features = ["clone-impls", "derive", "full", "parsing", "printing"] }

[dev-dependencies]
console = "0.16.0"
criterion = "0.7"
prettyplease = "0.2.20"
similar = "2.6.0"
syn = { version = "2.0.3", features = ["full"] }

[features]
# Use every feature to aid testing. `askama_macros` will opt-out of default features.
default = [
"alloc",
"blocks",
"code-in-doc",
"config",
"external-sources",
Expand All @@ -54,7 +52,6 @@ default = [
]

alloc = []
blocks = ["syn/full"]
code-in-doc = ["dep:pulldown-cmark"]
config = [
"external-sources",
Expand Down
Loading