3 个不稳定版本

使用旧的 Rust 2015

0.3.1 2018年2月18日
0.3.0 2018年2月18日
0.2.0 2018年2月17日

#17 in #html-xml

每月下载 22

Apache-2.0

31KB
394

rust-tags

Crates.io Crates.io

此项目仍在进行中。

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

与其他模板库不同的是,您的文档简单定义为普通函数调用。这可以让您安全地构建无 XSS 漏洞的文档。

这种方法的另一个优点是,可以使用 Rust 表达诸如部分模板等特性,利用 Rust 所有的强大功能。

示例

extern crate rust_tags;

use rust_tags::tags::*;
use rust_tags::tags::title;
use rust_tags::attributes::*;

fn main() {
    let frag = html(&[
        head(&[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);
}

使用 rust-tags 的项目

发行说明

0.3.1 2018-02-18

修复属性值转义中的错误。

0.3.0 2018-02-18

首次可用版本。

发布

  1. Cargo.toml 中升级版本
  2. 更新 README.md 中的发行说明
  3. 提交更改
  4. 创建并推送标签: git tag v<version>; git push origin v<version>
  5. 在 crates.io 上发布: cargo publish

作者

Jason Longshore [email protected]

许可证

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

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

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

无运行时依赖项