pub struct TextFunction { /* private fields */ }Expand description
Tera template function that can localize a message.
It contains an Arc shared reference of fluent bundle.
Usage assuming it was registered as text:
{{ text(id="hello-wold", lang="en", examplearg=foo, n=3, bla=true) }}How types that will be handled:
null: will be ignoredstring: will be passed to the fluent template as isnumber: will be passed as is with default settings (for now), errors if the number isn’t representable asf64.bool: will be passed as the stringstrueandfalseobject|array: will throw a type error
Implementations§
Source§impl TextFunction
impl TextFunction
Sourcepub fn new(
language_engine: Arc<LanguageEngine>,
context_getter: TextFunctionContextGetter,
) -> Self
pub fn new( language_engine: Arc<LanguageEngine>, context_getter: TextFunctionContextGetter, ) -> Self
Create a new TextFunction using a LanguageEngine that can be shared between multiple data structures.
The language_getter is a callback that returns the language to use if the lang argument of the text function is not set. See TextFunctionContextGetter for a more detailed explanation.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TextFunction
impl !UnwindSafe for TextFunction
impl Freeze for TextFunction
impl Send for TextFunction
impl Sync for TextFunction
impl Unpin for TextFunction
impl UnsafeUnpin for TextFunction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more