2010-09-23 23:00:13 +00:00
|
|
|
module Locomotive
|
|
|
|
module Import
|
2010-10-28 23:36:45 +00:00
|
|
|
class Snippets < Base
|
2010-09-23 23:00:13 +00:00
|
|
|
|
2010-10-28 23:36:45 +00:00
|
|
|
def process
|
2011-06-17 21:32:54 +00:00
|
|
|
Dir[File.join(theme_path, 'app', 'views', 'snippets', '*')].each do |snippet_path|
|
2010-10-28 23:36:45 +00:00
|
|
|
self.log "path = #{snippet_path}"
|
2010-09-23 23:00:13 +00:00
|
|
|
|
|
|
|
name = File.basename(snippet_path, File.extname(snippet_path)).parameterize('_')
|
2010-10-28 23:36:45 +00:00
|
|
|
|
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
|
|
|
|
2011-06-17 21:32:54 +00:00
|
|
|
snippet.template = File.read(snippet_path)
|
2010-10-28 23:36:45 +00:00
|
|
|
|
2010-09-26 22:31:50 +00:00
|
|
|
snippet.save!
|
2010-09-23 23:00:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|