Sha256: 752c83b395e1d4547dc74ead1eb066b1adb8a71c8b8b59e949f3e8dcb7aa20a1
Contents?: true
Size: 806 Bytes
Versions: 1
Compression:
Stored size: 806 Bytes
Contents
#!/usr/bin/env ruby require 'mustache' require 'yaml' if STDIN.stat.size > 0 doc = STDIN.read if doc =~ /^(\s*---(.*)---\s*)/m data = YAML.load($2.strip) puts Mustache.render(doc.sub($1, ''), data) else puts doc end else puts <<-usage Usage: cat data.yml template.mustache | mustache Expects a single Mustache template on STDIN complete with YAML frontmatter. Runs template.mustache through Mustache, using the data in data.yml to replace sections and variables. Useful when developing templates before hooking them into your website or whatnot. The data.yml file should start with --- on a single line and end with --- on a single line, e.g. --- names: [ {name: chris}, {name: mark}, {name: scott} ] --- The converted document will be printed on STDOUT. usage end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mustache-0.5.0 | bin/mustache |