我在配置文件夹中有一堆 YAML 文件,在模板文件夹中有一堆模板。我的用例是基于 yaml 配置和模板生成文本文件。我想看看是否可以使用 python 诱人的引擎来解决这个问题。
我看到模板引擎用于 Web 开发环境。我的用例非常相似(但不一样)。我想生成一些文本。它不需要显示在网页上。相反,它应该只生成一个文本文件。
示例输入:配置文件夹:config/yaml1、config/yaml2、config/yaml3.. 模板:template/template1、template/template2、template3。
输出
scripts/script1, script2, script3
脚本数量 = 模板数量
有 2 种类型的模板
一种直接/直接替换示例
YAML1:
Titles:4
SubTitles:10
Template1:
Number of Titles {Titles} where as Number of Subtitles is {SubTitles}
其他模板是嵌套模板。基本上模板需要循环基于 YAML 示例:
YAML2:
Book: "The Choice of using Choice"
Author: "Unknown1"
Book: "Chasing Choices"
Author:"Known2"
Template2
Here are all the Books with Author Info
The author of the {Book} is {Author}
预期的输出是一个单一的文本文件,具有
标题数 4 其中字幕数为 10 The Choice of using Choice 的作者未知 1 Chasing Choices 的作者已知 2
有人可以向我发布正确的方向吗?