Skip to main content

FilterEnv

Struct FilterEnv 

Source
#[non_exhaustive]
pub struct FilterEnv { pub timezone: Tz, pub page: Option<Value>, pub kwargs: Vec<(String, Value)>, pub input_safe: bool, pub args_safe: Vec<bool>, /* private fields */ }
Expand description

What an engine-neutral filter can see of the build and of the call.

Liquid builds one with FilterEnv::new, which leaves everything past the time zone empty, so its filters behave as before. Nunjucks fills in the rest.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§timezone: Tz

The zone a Date input is printed in, as JavaScript’s String(date) prints it.

§page: Option<Value>

The page’s data, which a JavaScript filter reads as this.page.

§kwargs: Vec<(String, Value)>

The keyword arguments of the call, in the order written. Nunjucks also passes them as a last object argument, with __keywords: true, which stays in the arguments a filter gets; this is the same data taken apart. Liquid passes none here.

§input_safe: bool

The input is a SafeString (from safe, escape or a macro). The filter gets its text as a string, as String(input) would give it.

§args_safe: Vec<bool>

Which of the arguments are SafeStrings, by position.

Implementations§

Source§

impl FilterEnv

Source

pub fn new(timezone: Tz) -> Self

Source

pub fn any_safe(&self) -> bool

Whether any of the input and the arguments is a SafeString.

Source

pub fn returns_input(&self)

A filter calls this when the value it returns is the input object itself, as JavaScript’s return input is. Nunjucks then keeps a SafeString input safe. A filter that builds a new string, even an equal one, must not call it.

Source

pub fn did_return_input(&self) -> bool

Whether the filter called FilterEnv::returns_input.

Trait Implementations§

Source§

impl Clone for FilterEnv

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FilterEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.