pub struct LiquidTemplate { /* private fields */ }

Implementations§

source§

impl LiquidTemplate

source

pub fn new<P: AsRef<str>>(path: P) -> Self

Examples found in repository?
examples/render.rs (line 4)
3
4
5
6
fn render(template_src: &str, output_path: &str) {
    let rendered = LiquidTemplate::new(template_src).render();
    std::fs::write(output_path, rendered).unwrap();
}
More examples
Hide additional examples
examples/codegen.rs (line 31)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn main() {
    let mut args = std::env::args().collect::<Vec<_>>();

    let mut get_arg = |key: &str| {
        let key_idx = args
            .iter()
            .enumerate()
            .find(|&(_idx, e)| e == key)
            .unwrap_or_else(|| {
                eprintln!("Unable to get {} CLI argument", key);
                print_usage_and_exit()
            })
            .0;
        let _key = args.remove(key_idx);
        if key_idx >= args.len() {
            eprintln!("No {} CLI option given", key);
            print_usage_and_exit();
        }
        let value = args.remove(key_idx);
        value
    };

    let template_path = get_arg("--template");
    let output_path = get_arg("--write-to");

    let rendered = lib_ruby_parser_nodes::LiquidTemplate::new(template_path).render();
    std::fs::write(output_path, rendered).unwrap();
}
source

pub fn new_eval<S: AsRef<str>>(src: S) -> Self

source

pub fn with_filter<F>(self, f: F) -> Selfwhere F: Into<Box<dyn ParseFilter>>,

source

pub fn with_global(self, name: &str, value: Value) -> Self

source

pub fn render(self) -> String

Examples found in repository?
examples/render.rs (line 4)
3
4
5
6
fn render(template_src: &str, output_path: &str) {
    let rendered = LiquidTemplate::new(template_src).render();
    std::fs::write(output_path, rendered).unwrap();
}
More examples
Hide additional examples
examples/codegen.rs (line 31)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn main() {
    let mut args = std::env::args().collect::<Vec<_>>();

    let mut get_arg = |key: &str| {
        let key_idx = args
            .iter()
            .enumerate()
            .find(|&(_idx, e)| e == key)
            .unwrap_or_else(|| {
                eprintln!("Unable to get {} CLI argument", key);
                print_usage_and_exit()
            })
            .0;
        let _key = args.remove(key_idx);
        if key_idx >= args.len() {
            eprintln!("No {} CLI option given", key);
            print_usage_and_exit();
        }
        let value = args.remove(key_idx);
        value
    };

    let template_path = get_arg("--template");
    let output_path = get_arg("--write-to");

    let rendered = lib_ruby_parser_nodes::LiquidTemplate::new(template_path).render();
    std::fs::write(output_path, rendered).unwrap();
}

Auto Trait Implementations§

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
§

impl<T> Any for Twhere T: Any,