YAML结构模板加工胶
yglu的Python项目详细描述
伊格卢瓦!?在
Yglu是用高级表达式语言扩充的YAML。与通常的文本模板不同,Yglu依赖于YAML结构,并利用其结合了YAQL查询语言的标记系统。在
这种关联支持模板化和函数化处理,有点像YAML节点是电子表格单元一样。在
Yglu输入文档是纯有效的YAML,使用tags作为计算节点。在
input ^{pr 1}$ | output ^{pr 2}$ |
在上面的例子中,names
序列是隐藏的,image
是一个函数(类似于模板块),而{
由于经常需要这样的操作,Yglu提供了一个!for
标记,用于合并在函数上迭代的序列:
更多示例请参见测试samples。在
安装
pip3 install yglu
跑
Usage: yglu [options] [<filename>]
Options:
-v - -version Print version and exit.
-h - -help Print help and exit.
标签
标记指定文档结构的更改。在
Tag | Description |
---|---|
^{ | Evaluate an expression. The result can be a scalar, mapping or sequence. Can also be used in mapping keys. |
^{ | Hide the node in the output but keep it accessible from expressions. Can be an expression. |
^{ | Make the node reusable in expressions as a function. |
^{ | Conditional merge. See if.yml. |
^{ | Merge the results of a function applied to all items of a sequence . See for.yml. |
^{ | Apply a function or function block to a block. See function.yml. |
表达式
表达式是用YAQL编写的。在
它们在定义了以下变量的上下文中进行计算:
Variable | Description |
---|---|
^{ | Refers to the current document root. Can be omitted at the beginning of the expression if it starts with a dot. |
^{ | Implicit argument of functions. |
^{ | Gives access to environment variables. Disabled by default. Set the ^{ |
^{ | Refers to the current function block node in order to access its children nodes. See function.yml |
内置函数
除了standard YAQL library,Yglu还定义了以下函数:
Function | Description |
---|---|
^{ | Imports another document in the current node. By default, it is only permitted to import files from within the directory hierarchy of the input file. Set ^{ |
- 项目
标签: