#html-templating #templating #html #template #html-xml #xml

已撤回 rustags

Rust的HTML模板库

使用旧的Rust 2015

0.1.0 2018年2月17日

#18 in #html-xml

Apache-2.0

32KB
394

rustags

这是一个正在进行中的项目。

这是一个用于Rust编程语言的HTML模板库。它深受Scalatags的启发。

与其他模板库不同的是,您的文档简单地定义为普通函数调用。这,以及其他因素,允许您安全地构建不受XSS漏洞影响的文档。

这种方法的另一个优点是,可以使用Rust轻松表达部分模板等功能,因为可以使用其全部功能。

示例

use core::*;
use tags::*;
use attributes::*;

let frag = html(&[
    head(&[tags::title(&["My Blog".into()])]),
    body(&[
        div(&[
            "Jason Longshore".into(),

            hr(&[]),

            // note that the hello world is escaped

            a(&[href("#"), "My Blog <hello world />".into()]),

            br(),
            br()
        ])
    ])
]);

println!(frag.data);

作者

Jason Longshore nospam@hence.todo.com

许可证

版权所有 (C) 2018 Jason Longshore (https://longshore.info/).

根据Apache许可证第2版(“许可证”)授权;除非遵守许可证,否则不得使用此项目。您可以在https://apache.ac.cn/licenses/LICENSE-2.0获取许可证副本。

除非适用法律要求或书面同意,否则在许可证下分发的软件按“原样”基础分发,不提供任何明示或暗示的保证或条件。有关许可证的具体语言、许可和限制,请参阅许可证。

无运行时依赖