mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 13:30:59 +00:00
Move filter list closer to the actual filters, add docs
This commit is contained in:
parent
32a9dd5f2e
commit
23279c3bce
@ -16,6 +16,23 @@ use std::fmt;
|
||||
use super::Result;
|
||||
|
||||
|
||||
// This is used by the code generator to decide whether a named filter is part of
|
||||
// Askama or should refer to a local `filters` module. It should contain all the
|
||||
// filters shipped with Askama, even the optional ones (since optional inclusion
|
||||
// in the const vector based on features seems impossible right now).
|
||||
pub const BUILT_IN_FILTERS: [&str; 9] = [
|
||||
"e",
|
||||
"escape",
|
||||
"format",
|
||||
"lower",
|
||||
"lowercase",
|
||||
"trim",
|
||||
"upper",
|
||||
"uppercase",
|
||||
"json", // Optional feature; reserve the name anyway
|
||||
];
|
||||
|
||||
|
||||
fn escapable(b: &u8) -> bool {
|
||||
*b == b'<' || *b == b'>' || *b == b'&'
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
use filters;
|
||||
use parser::{self, Cond, Expr, Node, Target, WS};
|
||||
use path;
|
||||
|
||||
@ -262,7 +263,7 @@ impl<'a> Generator<'a> {
|
||||
return;
|
||||
}
|
||||
|
||||
if BUILT_IN_FILTERS.contains(&name) {
|
||||
if filters::BUILT_IN_FILTERS.contains(&name) {
|
||||
self.write(&format!("::askama::filters::{}(&", name));
|
||||
} else {
|
||||
self.write(&format!("filters::{}(&", name));
|
||||
@ -729,15 +730,3 @@ impl<'a, T: 'a> SetChain<'a, T> where T: cmp::Eq + hash::Hash {
|
||||
}
|
||||
|
||||
type MacroMap<'a> = HashMap<&'a str, (WS, &'a str, Vec<&'a str>, Vec<Node<'a>>, WS)>;
|
||||
|
||||
const BUILT_IN_FILTERS: [&str; 9] = [
|
||||
"e",
|
||||
"escape",
|
||||
"format",
|
||||
"lower",
|
||||
"lowercase",
|
||||
"trim",
|
||||
"upper",
|
||||
"uppercase",
|
||||
"json", // Optional feature; reserve the name anyway
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user