1 stable release

1.0.0 Oct 23, 2023

#462 in Template engine

Download history 20/week @ 2024-06-02 15/week @ 2024-06-09 22/week @ 2024-06-16 19/week @ 2024-06-23 3/week @ 2024-06-30 7/week @ 2024-07-07 23/week @ 2024-07-14 22/week @ 2024-07-21 29/week @ 2024-07-28 13/week @ 2024-08-04 17/week @ 2024-08-11 10/week @ 2024-08-18 22/week @ 2024-08-25 11/week @ 2024-09-01 13/week @ 2024-09-08 7/week @ 2024-09-15

55 downloads per month
Used in 7 crates (5 directly)

MIT/Apache

6KB

Late format

This crate provides a simple way of formatting parameters in a runtime string, with runtime parameter names.

This is an alternative to using complex template engines.

Example

use late_format::LateFormat;
use maplit::hashmap;

let user_string: String = "some user string: {id}".into();
assert_eq!(
    "some user string: x",
    user_string.late_format(hashmap!{"id".into() => "x".into()})
);

let user_string: String = r#"some user string: {"id"}"#.into();
assert_eq!(
    "some user string: id",
    user_string.late_format(hashmap!{"id".into() => "x".into()})
);

let user_string: String = r#"some user string: {  "id"  }"#.into();
assert_eq!(
    "some user string: id",
    user_string.late_format(hashmap!{"id".into() => "x".into()})
);

let user_string: String = "some user string: {id}".into();
assert_eq!(
    "some user string: None",
    user_string.late_format(hashmap!{})
);

Dependencies

~2.3–4MB
~69K SLoC