1 stable release

1.0.0 Oct 23, 2023

#391 in Template engine

Download history 10/week @ 2024-03-11 7/week @ 2024-03-18 6/week @ 2024-03-25 53/week @ 2024-04-01 86/week @ 2024-04-08 51/week @ 2024-04-15 78/week @ 2024-04-22 94/week @ 2024-04-29 58/week @ 2024-05-06 19/week @ 2024-05-13 22/week @ 2024-05-20 13/week @ 2024-05-27 19/week @ 2024-06-03 21/week @ 2024-06-10 18/week @ 2024-06-17 20/week @ 2024-06-24

79 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.5–4MB
~73K SLoC