Split maruku and markaby support into their own folders
This commit is contained in:
parent
dbaf43c1b5
commit
397944faeb
5 changed files with 18 additions and 15 deletions
|
@ -26,6 +26,7 @@ module Generators
|
|||
|
||||
if (args[0] === args[1])
|
||||
newext = case File.extname(args.first)
|
||||
# Middleman.supported_formats.map { |ext| ".#{ext}" }
|
||||
when '.haml', '.erb', '.mab', '.maruku'
|
||||
'.html'
|
||||
when '.sass'
|
||||
|
@ -51,7 +52,7 @@ module Generators
|
|||
file(action.downcase.gsub(/[^a-z0-9]+/, '_').to_sym, action, action.gsub('public/', ''))
|
||||
end
|
||||
|
||||
glob! "views", %w(haml sass erb builder mab maruku)
|
||||
glob! "views", (Middleman.supported_formats << "sass")
|
||||
end
|
||||
|
||||
add :build, Builder
|
||||
|
|
|
@ -3,12 +3,6 @@ require 'haml'
|
|||
require 'compass' #must be loaded before sinatra
|
||||
require 'sinatra/base'
|
||||
|
||||
# Include markaby support
|
||||
require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-markaby', 'lib', 'sinatra', 'markaby')
|
||||
|
||||
# Include maruku support
|
||||
require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-maruku', 'lib', 'sinatra', 'maruku')
|
||||
|
||||
# Include content_for support
|
||||
require File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra-content-for', 'lib', 'sinatra', 'content_for')
|
||||
|
||||
|
@ -17,9 +11,9 @@ class Middleman < Sinatra::Base
|
|||
set :static, true
|
||||
set :root, Dir.pwd
|
||||
set :environment, defined?(MIDDLEMAN_BUILDER) ? :build : :development
|
||||
|
||||
helpers Sinatra::Markaby
|
||||
helpers Sinatra::Maruku
|
||||
|
||||
set :supported_formats, %w(haml erb builder)
|
||||
|
||||
helpers Sinatra::ContentFor
|
||||
|
||||
def self.run!(options={}, &block)
|
||||
|
@ -84,6 +78,7 @@ class Middleman < Sinatra::Base
|
|||
end
|
||||
end
|
||||
|
||||
# All other files
|
||||
get /(.*)/ do |path|
|
||||
path << "index.html" if path.match(%r{/$})
|
||||
path.gsub!(%r{^/}, '')
|
||||
|
@ -91,9 +86,8 @@ class Middleman < Sinatra::Base
|
|||
|
||||
result = nil
|
||||
begin
|
||||
%w(haml erb builder maruku mab).detect do |renderer|
|
||||
options.supported_formats.detect do |renderer|
|
||||
next false if !File.exists?(File.join(options.views, "#{path}.#{renderer}"))
|
||||
renderer = "markaby" if renderer == "mab"
|
||||
result = send(renderer.to_sym, path.to_sym)
|
||||
end
|
||||
rescue Haml::Error => e
|
||||
|
@ -103,6 +97,4 @@ class Middleman < Sinatra::Base
|
|||
|
||||
result || pass
|
||||
end
|
||||
end
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'middleman', 'helpers')
|
||||
end
|
4
lib/middleman/markaby.rb
Normal file
4
lib/middleman/markaby.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Include markaby support
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'sinatra-markaby', 'lib', 'sinatra', 'markaby')
|
||||
Middleman.helpers Sinatra::Markaby
|
||||
Middleman.supported_formats << "mab"
|
4
lib/middleman/maruku.rb
Normal file
4
lib/middleman/maruku.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Include maruku support
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'sinatra-maruku', 'lib', 'sinatra', 'maruku')
|
||||
Middleman.helpers Sinatra::Maruku
|
||||
Middleman.supported_formats << "maruku"
|
2
spec/fixtures/sample/init.rb
vendored
Normal file
2
spec/fixtures/sample/init.rb
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
require File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "middleman", "maruku")
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "middleman", "markaby")
|
Loading…
Add table
Reference in a new issue