Add string helpers for platform expressions
This commit is contained in:
@@ -202,6 +202,13 @@ impl PlatformExprStrategy {
|
|||||||
engine.register_fn("iff", |condition: bool, when_true: Dynamic, when_false: Dynamic| {
|
engine.register_fn("iff", |condition: bool, when_true: Dynamic, when_false: Dynamic| {
|
||||||
if condition { when_true } else { when_false }
|
if condition { when_true } else { when_false }
|
||||||
});
|
});
|
||||||
|
engine.register_fn("contains", |value: &str, needle: &str| value.contains(needle));
|
||||||
|
engine.register_fn("starts_with", |value: &str, prefix: &str| value.starts_with(prefix));
|
||||||
|
engine.register_fn("ends_with", |value: &str, suffix: &str| value.ends_with(suffix));
|
||||||
|
engine.register_fn("lower", |value: &str| value.to_lowercase());
|
||||||
|
engine.register_fn("upper", |value: &str| value.to_uppercase());
|
||||||
|
engine.register_fn("trim", |value: &str| value.trim().to_string());
|
||||||
|
engine.register_fn("strlen", |value: &str| value.chars().count() as i64);
|
||||||
Self { config, engine }
|
Self { config, engine }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user