Skip to content

Instantly share code, notes, and snippets.

@tarnagas
Created August 16, 2017 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarnagas/32fd5ca35e89bdf56f2eaf89f375ba00 to your computer and use it in GitHub Desktop.
Save tarnagas/32fd5ca35e89bdf56f2eaf89f375ba00 to your computer and use it in GitHub Desktop.
Sample use of liquid (gem) to generate YAML
#!/usr/bin/env ruby
require 'liquid'
template = <<-HEREDOC
data:
{%- for item in plops %}
- {{ item }}
{%- endfor %}
host: "sample.local"
HEREDOC
puts Liquid::Template
.parse(template)
.render(
'plops' => (1..6)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment