Permalink
Browse files

Fix nil errors in the mustache plugin

  • Loading branch information...
1 parent db9cfff commit b586a3afb34388c882bf2e8a6ab3ea2f114f01e3 @quirkey quirkey committed Oct 27, 2010
Showing with 7 additions and 3 deletions.
  1. +6 −3 lib/soca/plugins/mustache.rb
  2. +1 −0 soca.gemspec
@@ -17,16 +17,19 @@ class Mustache < Soca::Plugin
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}"
+ 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('.') : basename[0] + ".html"
File.open(File.join(dir, new_file), 'w') do |f|
- f << Mustache.render(File.read(file), vars)
+ f << ::Mustache.render(File.read(file), vars)
end
Soca.logger.debug "Wrote to #{new_file}"
end
View
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
"lib/soca/plugin.rb",
"lib/soca/plugins/compass.rb",
"lib/soca/plugins/jim.rb",
+ "lib/soca/plugins/mustache.rb",
"lib/soca/pusher.rb",
"lib/soca/templates/Jimfile",
"lib/soca/templates/config.js.erb",

0 comments on commit b586a3a

Please sign in to comment.