Sha256: 2910e0bd1af0eeb6c8bd1ff69b3150a0e2a999113f7e2780266252ab62496dcc
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require 'mustache' module Soca module Plugins class Mustache < Soca::Plugin name 'mustache' # Run the mustache plugin. # Available options: # # * :files - Run these files through mustache. Can be an array of patterns # or a single file. The default is '*.mustache'. # * :vars - Additional variables to interpolate. By default the `env` and # `config` are interpolated. # def run(options = {}) file_patterns = options[:files] || '*.mustache' files = Dir[*[file_patterns].flatten] vars = { :env => pusher.env, :config => pusher.config }.merge(options[:vars] || {}) Soca.logger.debug "Mustache vars: #{vars.inspect}" files.each do |file| Soca.logger.debug "Running #{file} through mustache." basename = File.basename(file) dir = File.dirname(file) parts = basename.split(/\./) new_file = parts.length > 2 ? parts[0..-2].join('.') : parts[0] + ".html" File.open(File.join(dir, new_file), 'w') do |f| f << ::Mustache.render(File.read(file), vars) end Soca.logger.debug "Wrote to #{new_file}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
soca-0.2.0 | lib/soca/plugins/mustache.rb |