#template #mustache #publisher #命令行工具 #cli #数据文件

app pbl

一个简单的命令行应用程序,用于从结构化数据和模板中渲染模板

5 个版本

0.2.1 2022年1月17日
0.1.3 2021年3月13日
0.1.2 2021年3月13日
0.1.1 2021年3月13日
0.1.0 2021年3月13日

#114 in 渲染

自定义许可证

7KB

发布者 (pbl)

发布者是一个简单的命令行应用程序,用于从结构化数据和模板中渲染模板。

用法

A simple command line application for rendering templates from structured data and a template.

USAGE:
    pbl --data <DATA> --template <TEMPLATE>

OPTIONS:
    -d, --data <DATA>            Path to the data file
    -h, --help                   Print help information
    -t, --template <TEMPLATE>    Path to the template file
    -V, --version                Print version information

示例

给定一个数据文件,data.json

{
  "title": "My Blog",
  "body": "blah"
}

和一个模板,template.mustache

<html lang="en">
  <head>
    <title>{{title}}</title>
  </head>
  <body>
    {{body}}
  </body>
</html>

以下命令将渲染模板

pbl render --data data.json --template template.mustache

默认情况下,结果将写入 stdout,并如下所示

<html lang="en">
<head>
  <title>My Blog</title>
</head>
<body>
blah
</body>
</html>

为什么创建 pbl?

pbl 的第一个用例是为一个给定描述项目的数据文件的项目创建一个模板化的 CONTRIBUTING.md 文档。

路线图

  • 添加对转换的支持。
  • 添加对 json-e 的支持。
  • 可以指定输出路径。
  • 添加对多个模板引擎的支持。
  • 添加对多种数据格式的支持。
  • 给定一个模板,解析它所需的数据,并返回一个空的序列化数据文件或提示输入值。

依赖项

~2.3–3.5MB
~62K SLoC