generalize renderers
This commit is contained in:
parent
4a6eb26d58
commit
5cc9470ae9
|
@ -22,7 +22,7 @@ module Generators
|
||||||
|
|
||||||
if (args[0] === args[1])
|
if (args[0] === args[1])
|
||||||
newext = case File.extname(args.first)
|
newext = case File.extname(args.first)
|
||||||
when '.haml', '.mab', '.maruku'
|
when '.haml', '.erb', '.mab', '.maruku'
|
||||||
'.html'
|
'.html'
|
||||||
when '.sass'
|
when '.sass'
|
||||||
'.css'
|
'.css'
|
||||||
|
@ -48,7 +48,7 @@ module Generators
|
||||||
file(action.downcase.gsub(/[^a-z0-9]+/, '_').to_sym, action, action.gsub('public/', ''))
|
file(action.downcase.gsub(/[^a-z0-9]+/, '_').to_sym, action, action.gsub('public/', ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
glob! "views", %w(haml sass mab maruku)
|
glob! "views", %w(haml sass erb builder mab maruku)
|
||||||
end
|
end
|
||||||
|
|
||||||
add :build, Builder
|
add :build, Builder
|
||||||
|
|
|
@ -49,23 +49,24 @@ class Middleman < Sinatra::Base
|
||||||
get /(.*)/ do |path|
|
get /(.*)/ do |path|
|
||||||
path << "index.html" if path.match(%r{/$})
|
path << "index.html" if path.match(%r{/$})
|
||||||
path.gsub!(%r{^/}, '')
|
path.gsub!(%r{^/}, '')
|
||||||
|
|
||||||
template = path.gsub(File.extname(path), '').to_sym
|
template = path.gsub(File.extname(path), '').to_sym
|
||||||
if path.match /.html$/
|
|
||||||
if File.exists? File.join(options.views, "#{template}.haml")
|
result = nil
|
||||||
haml(template)
|
|
||||||
elsif File.exists? File.join(options.views, "#{template}.maruku")
|
%w(haml erb builder maruku mab sass).each do |renderer|
|
||||||
maruku(template)
|
next if !File.exists?(File.join(options.views, "#{template}.#{renderer}"))
|
||||||
elsif File.exists? File.join(options.views, "#{template}.mab")
|
|
||||||
markaby(template)
|
renderer = "markaby" if renderer == "mab"
|
||||||
|
result = if renderer == "sass"
|
||||||
|
content_type 'text/css', :charset => 'utf-8'
|
||||||
|
sass(template, Compass.sass_engine_options)
|
||||||
else
|
else
|
||||||
pass
|
send(renderer.to_sym, template)
|
||||||
end
|
end
|
||||||
elsif path.match /.css$/
|
|
||||||
content_type 'text/css', :charset => 'utf-8'
|
break
|
||||||
sass(template, Compass.sass_engine_options)
|
|
||||||
else
|
|
||||||
pass
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
result || pass
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue