freemarker 0.1.1

Apache FreeMarker 语义兼容的 Rust 模板引擎(freemarker-core 迁移)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! 安全工具 —— 对应 Java `freemarker.template.utility.SecurityUtilities`
//! (getSystemProperty:经 SecurityManager 读系统属性;
//! v1 用 std::env 直读,文档化差异)

/// 安全工具(对应 SecurityUtilities.java)
pub struct SecurityUtilities;

impl SecurityUtilities {
    /// 系统属性(Java `getSystemProperty(String key)`;v1 = std::env::var)
    pub fn get_system_property(key: &str) -> Option<String> {
        std::env::var(key).ok()
    }

    /// 系统属性带默认值(Java :46-)
    pub fn get_system_property_or(key: &str, def_value: &str) -> String {
        std::env::var(key).unwrap_or_else(|_| def_value.to_string())
    }
}