engine/lib/locomotive/import/snippets.rb

21 lines
525 B
Ruby
Raw Normal View History

2010-09-23 23:00:13 +00:00
module Locomotive
module Import
class Snippets < Base
2010-09-23 23:00:13 +00:00
def process
2011-06-17 21:32:54 +00:00
Dir[File.join(theme_path, 'app', 'views', 'snippets', '*')].each do |snippet_path|
self.log "path = #{snippet_path}"
2010-09-23 23:00:13 +00:00
name = File.basename(snippet_path, File.extname(snippet_path)).parameterize('_')
snippet = site.snippets.where(:slug => name).first || site.snippets.build(:name => name)
2010-09-23 23:00:13 +00:00
2011-06-17 21:32:54 +00:00
snippet.template = File.read(snippet_path)
snippet.save!
2010-09-23 23:00:13 +00:00
end
end
end
end
end