[−][src]Struct liquid_lib::stdlib::Truncate
truncate
shortens a string down to the number of characters passed as a parameter.
Note that this function operates on grapheme clusters (or user-perceived character), rather than Unicode code points. Each grapheme cluster may be composed of more than one Unicode code point, and does not necessarily correspond to rust's conception of a character.
If the number of characters specified is less than the length of the string, an ellipsis
(...
) is appended to the string and is included in the character count.
Custom ellipsis
truncate
takes an optional second parameter that specifies the sequence of characters to be
appended to the truncated string. By default this is an ellipsis (...
), but you can specify a
different sequence.
The length of the second parameter counts against the number of characters specified by the
first parameter. For example, if you want to truncate a string to exactly 10 characters, and
use a 3-character ellipsis, use 13 for the first parameter of truncate
, since the ellipsis
counts as 3 characters.
No ellipsis
You can truncate to the exact number of characters specified by the first parameter and show no trailing characters by passing a blank string as the second parameter.
Trait Implementations
impl Clone for Truncate
[src]
impl FilterReflection for Truncate
[src]
fn name(&self) -> &'static str
[src]
fn description(&self) -> &'static str
[src]
fn positional_parameters(&self) -> &'static [ParameterReflection]
[src]
fn keyword_parameters(&self) -> &'static [ParameterReflection]
[src]
impl ParseFilter for Truncate
[src]
fn parse(&self, args: FilterArguments) -> Result<Box<dyn Filter>>
[src]
fn reflection(&self) -> &dyn FilterReflection
[src]
Auto Trait Implementations
impl RefUnwindSafe for Truncate
impl Send for Truncate
impl Sync for Truncate
impl Unpin for Truncate
impl UnwindSafe for Truncate
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ParseFilterClone for T where
T: 'static + ParseFilter + Clone,
T: 'static + ParseFilter + Clone,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,