philipw/yaml-template-generator
Composer 安装命令:
composer require philipw/yaml-template-generator
包简介
README 文档
README
YAML/JSON Template Engine
This turns YAML/JSON files into templates that allows the user to pipe in params.
Example YAML template:
foo: {{ foo }}
Example params file:
{
"foo" : "bar"
}
Output:
foo: bar
Universal Usage:
docker run -v ${workingdir}:/config \
-e "TEMPLATEENGINE_TEMPLATEFILE=example/template.yaml" \
-e "TEMPLATEENGINE_OUTPUTFILE=example/output.yaml" \
-e "TEMPLATEENGINE_PARAMS=example/params.json" \
-i philipw/yamltemplates
Bash Function: Put this bash function in your bash profile and you will be able to generate a templated yaml from anywhere on the CLI
function generateYaml() {
TEMPLATEENGINE_TEMPLATEFILE=$0
TEMPLATEENGINE_OUTPUTFILE=$1
TEMPLATEENGINE_PARAMS=$2
TEMPLATEENGINE_MIXIN=$3
workingdir=$(pwd)
docker run -v ${workingdir}:/config \
-e "TEMPLATEENGINE_TEMPLATEFILE=${TEMPLATEENGINE_TEMPLATEFILE}" \
-e "TEMPLATEENGINE_OUTPUTFILE=${TEMPLATEENGINE_OUTPUTFILE}" \
-e "TEMPLATEENGINE_PARAMS=${TEMPLATEENGINE_PARAMS}" \
-e "TEMPLATEENGINE_MIXIN=${TEMPLATEENGINE_MIXIN}" \
-i philipw/yamltemplates
}
See examples folder for a more complete example.
PHP Lib Usage
Install via composer: philipw/yaml-template-generator
use TemplateEngine\Config;
use TemplateEngine\Template;
$config = new Config(__DIR__.'/example/params.json');
$template = new Template(
$config,
__DIR__.'/example/example.yaml'
);
$template->writeRenderedOutput(__DIR__.'/output.yaml');
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2019-04-01