2010-09-23 23:00:13 +00:00
|
|
|
module Locomotive
|
|
|
|
module Import
|
|
|
|
module Snippets
|
|
|
|
|
|
|
|
def self.process(context)
|
|
|
|
site, theme_path = context[:site], context[:theme_path]
|
|
|
|
|
|
|
|
Dir[File.join(theme_path, 'snippets', '*')].each do |snippet_path|
|
|
|
|
|
|
|
|
name = File.basename(snippet_path, File.extname(snippet_path)).parameterize('_')
|
2010-09-26 22:31:50 +00:00
|
|
|
|
|
|
|
snippet = site.snippets.where(:slug => name).first || site.snippets.build(:name => name)
|
2010-09-23 23:00:13 +00:00
|
|
|
|
2010-09-26 22:31:50 +00:00
|
|
|
snippet.template = File.read(snippet_path) # = site.snippets.create! :name => name, :template =>
|
|
|
|
|
|
|
|
snippet.save!
|
2010-09-23 23:00:13 +00:00
|
|
|
# puts "snippet = #{snippet.inspect}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|