pub struct TagBlock<'a: 'b, 'b> { /* private fields */ }
Expand description

An interface to access elements inside a block.

Implementations§

source§

impl<'a, 'b> TagBlock<'a, 'b>

source

pub fn next(&mut self) -> Result<Option<BlockElement<'a>>>

Returns the next element of the block, if any, similarly to an iterator.

However, if the input text reaches its end and the block is not closed, an error is returned instead.

source

pub fn escape_liquid(&mut self, allow_nesting: bool) -> Result<&'a str>

Retrieves all the content of this block as a String, regardless of being valid liquid or not.

Do not use this method in a block you already called .next() on.

Set the parameter allow_nesting of this function to true if you still want these tags to nest (so the number of {% name %} must be equal to the number of {% endname %}) of false if you don’t (only the first {% name %} is parsed, a single {% endname %} will always close the tag).

Panics

Will panic if used in a closed block.

source

pub fn parse_all( &mut self, options: &Language ) -> Result<Vec<Box<dyn Renderable>>>

A convenient method that parses every element remaining in the block.

source

pub fn parse_next( &mut self, options: &Language ) -> Result<Option<Box<dyn Renderable>>>

Parses the next element in the block just as if it weren’t inside any block.

Returns none if no element is left and raises the same errors as next().

source

pub fn assert_empty(self)

Checks whether the block was fully parsed its elements.

This must be added at the end of every block right before returning, so as to ensure that it doesn’t leave any unparsed element by accident.

Auto Trait Implementations§

§

impl<'a, 'b> !RefUnwindSafe for TagBlock<'a, 'b>

§

impl<'a, 'b> !Send for TagBlock<'a, 'b>

§

impl<'a, 'b> !Sync for TagBlock<'a, 'b>

§

impl<'a, 'b> Unpin for TagBlock<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for TagBlock<'a, 'b>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> Any for Twhere T: Any,