lib/susanoo/controllers/views.rb in susanoo-0.13.1 vs lib/susanoo/controllers/views.rb in susanoo-0.13.2
- old
+ new
@@ -14,11 +14,12 @@
end
[200, {'Content-Type' => 'text/html'}, [template.render(self)]]
end
def build(generator, options)
- file_pattern = File.join(project_root, 'src/views/**/*.{html,html.erb}')
+ extensions = ['erb', 'slim', 'haml', 'md', 'org', 'liquid', 'rdoc']
+ file_pattern = File.join(project_root, "src/views/**/*.{html,#{extensions.join(',')}}")
dest_path = File.join(project_root, 'www')
src_path = File.join(project_root, 'src')
Dir.glob(file_pattern) do |file|
template = Tilt.new file
@@ -27,12 +28,14 @@
file.gsub(src_path, ''))
# Create missing directories in destination path
FileUtils.mkpath dest_path
- # Remove erb extension name from destination path
- dest_file.gsub!('.erb', '') if File.extname(dest_file) == 'erb'
-
+ if extensions.include? File.extname(dest_file)[1..-1]
+ # Remove erb extension name from destination path
+ dest_file.gsub!(File.extname(dest_file), '')
+ dest_file = "#{dest_file}.html" if File.extname(dest_file).empty?
+ end
# Create the destination file
generator.create_file dest_file, template.render(self)
end
end
end