ecg is an ERB(eRuby) based, simple and powerful configration file generator for general purpose.
Ruby: 2.5 or higher
gem install ecg
See also ecg --help
ecg --values name=epaew --values email="[email protected]" < template.json.erb
{
"type": "user",
"name": "epaew",
"email": "[email protected]"
}
or
ecg config.yml < template.json.erb
{
"type": "user",
"name": "epaew",
"email": "[email protected]"
}
with
- template.json.erb
{ "type": "user", "name": "<%= name %>", "email": "<%= email %>" }
- config.yml
name: epaew email: [email protected]
ecg --values user.name=epaew --values user.email="[email protected]" < template.json.erb
{
"user": {
"name": "epaew",
"email": "[email protected]"
}
}
or
ecg config.yml < template.json.erb
{
"user": {
"name": "epaew",
"email": "[email protected]"
}
}
with
- template.json.erb
{ "user": { "name": "<%= user.name %>", "email": "<%= user.email %>" } }
- config.yml
user: name: epaew email: [email protected]
ecg config.yml < template.json.erb
{
"user": [
{
"name": "Kurimu"
},
{
"name": "Chizuru"
},
{
"name": "Minatsu"
},
{
"name": "Mahuyu"
}
]
}
with
- template.json.erb
{ "user": [ <% users.each_with_index do |user, i| %> { "name": "<%= user.name %>" <% unless i == users.count - 1 %> }, <% else %> } <% end %> <% end %> ] }
- config.yml
users: - name: Kurimu - name: Chizuru - name: Minatsu - name: Mahuyu