Sha256: db135ccbacbcf4201a2b34d6fbf586bdb823b2e7488415d8f8ca20fb00bdc413

Contents?: true

Size: 641 Bytes

Versions: 19

Compression:

Stored size: 641 Bytes

Contents

#!/usr/bin/env ruby

require 'sablon'
require 'json'

if ARGV.size < 1
  puts <<-HELP
cat <context path> | sablon <template path> [<output path>]
  HELP
  exit
end

template_path = File.expand_path(ARGV[0])
context_json = STDIN.readlines.join
context = JSON.parse(context_json)
config = context.delete("_sablon") || {}
section_properties = config.fetch("properties", {})

template = Sablon.template(template_path)

if !ARGV[1].nil? && !ARGV[1].empty?
  output_path = File.expand_path(ARGV[1])
  template.render_to_file(output_path, context, section_properties)
else
  $stdout.print template.render_to_string(context, section_properties)
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
sablon-0.4.1 exe/sablon
sablon-0.4.0 exe/sablon
sablon-0.3.2 exe/sablon
sablon-0.3.1 exe/sablon
sablon-0.3.0 exe/sablon
sablon-0.2.1 exe/sablon
sablon-0.2.0 exe/sablon
sablon-0.1.1 exe/sablon
sablon-0.1.0 exe/sablon
sablon-0.0.22 exe/sablon
sablon-0.0.21 exe/sablon
sablon-0.0.20 exe/sablon
sablon-0.0.19 exe/sablon
sablon-0.0.19.beta5 exe/sablon
sablon-0.0.19.beta4 exe/sablon
sablon-0.0.19.beta3 exe/sablon
sablon-0.0.19.beta2 exe/sablon
sablon-0.0.19.beta1 exe/sablon
sablon-0.0.18 exe/sablon