From 8d2c070104a05dcd5b00efd7a6ce47e45425731f Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Fri, 6 Aug 2010 09:59:38 -0700 Subject: [PATCH] enable less and builder support --- Rakefile | 4 +++- lib/middleman.rb | 13 +++++++++---- lib/middleman/base.rb | 11 ++++++----- lib/middleman/renderers/builder.rb | 23 +++++++++++++++++++++++ lib/middleman/{ => renderers}/erb.rb | 8 ++++---- lib/middleman/{ => renderers}/haml.rb | 0 lib/middleman/renderers/less.rb | 23 +++++++++++++++++++++++ lib/middleman/{ => renderers}/sass.rb | 0 middleman.gemspec | 23 ++++++++++++----------- 9 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 lib/middleman/renderers/builder.rb rename lib/middleman/{ => renderers}/erb.rb (83%) rename lib/middleman/{ => renderers}/haml.rb (100%) create mode 100644 lib/middleman/renderers/less.rb rename lib/middleman/{ => renderers}/sass.rb (100%) diff --git a/Rakefile b/Rakefile index 5a890094..915aea62 100644 --- a/Rakefile +++ b/Rakefile @@ -21,6 +21,8 @@ begin gem.add_dependency("sprockets") gem.add_dependency("sinatra", ">=1.0") gem.add_dependency("sinatra-content-for") + gem.add_dependency("less") + gem.add_dependency("builder") gem.add_dependency("rack-test") gem.add_dependency("yui-compressor") gem.add_dependency("haml", ">=3.0") @@ -51,4 +53,4 @@ end task :spec => :check_dependencies -task :default => [:cucumber, :spec] \ No newline at end of file +task :default => [:cucumber, :spec] diff --git a/lib/middleman.rb b/lib/middleman.rb index 189c7f16..2a172483 100755 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -11,10 +11,15 @@ module Middleman autoload :MinifyCSS, "middleman/rack/minify_css" end + module Renderers + autoload :ERb, "middleman/renderers/erb" + autoload :Builder, "middleman/renderers/builder" + autoload :Less, "middleman/renderers/less" + end + autoload :Base, "middleman/base" - autoload :ERb, "middleman/erb" - autoload :Haml, "middleman/haml" - autoload :Sass, "middleman/sass" + autoload :Haml, "middleman/renderers/haml" + autoload :Sass, "middleman/renderers/sass" autoload :Helpers, "middleman/helpers" -end \ No newline at end of file +end diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb index 24d05c84..95c60e46 100644 --- a/lib/middleman/base.rb +++ b/lib/middleman/base.rb @@ -126,10 +126,11 @@ module Middleman end end -require "middleman/erb" -# Haml is required & includes helpers -require "middleman/haml" -require "middleman/sass" +require "middleman/renderers/erb" +require "middleman/renderers/haml" +require "middleman/renderers/sass" +require "middleman/renderers/less" +require "middleman/renderers/builder" class Middleman::Base helpers Middleman::Helpers @@ -184,4 +185,4 @@ class Middleman::Base super end -end \ No newline at end of file +end diff --git a/lib/middleman/renderers/builder.rb b/lib/middleman/renderers/builder.rb new file mode 100644 index 00000000..10091e83 --- /dev/null +++ b/lib/middleman/renderers/builder.rb @@ -0,0 +1,23 @@ +require "builder" + +module Middleman + module Renderers + module Builder + def self.included(base) + base.supported_formats << "builder" + end + + def render_path(path, layout) + if template_exists?(path, :builder) + builder(path.to_sym, :layout => layout) + else + super + end + end + end + end +end + +class Middleman::Base + include Middleman::Renderers::Builder +end diff --git a/lib/middleman/erb.rb b/lib/middleman/renderers/erb.rb similarity index 83% rename from lib/middleman/erb.rb rename to lib/middleman/renderers/erb.rb index 5f5c0b54..ac273767 100755 --- a/lib/middleman/erb.rb +++ b/lib/middleman/renderers/erb.rb @@ -1,8 +1,8 @@ require "erb" module Middleman - module ERb - module Renderer + module Renderers + module ERb def self.included(base) base.supported_formats << "erb" end @@ -20,5 +20,5 @@ module Middleman end class Middleman::Base - include Middleman::ERb::Renderer -end \ No newline at end of file + include Middleman::Renderers::ERb +end diff --git a/lib/middleman/haml.rb b/lib/middleman/renderers/haml.rb similarity index 100% rename from lib/middleman/haml.rb rename to lib/middleman/renderers/haml.rb diff --git a/lib/middleman/renderers/less.rb b/lib/middleman/renderers/less.rb new file mode 100644 index 00000000..1034ee93 --- /dev/null +++ b/lib/middleman/renderers/less.rb @@ -0,0 +1,23 @@ +require "less" + +module Middleman + module Renderers + module Less + def self.included(base) + base.supported_formats << "less" + end + + def render_path(path, layout) + if template_exists?(path, :less) + less(path.to_sym) + else + super + end + end + end + end +end + +class Middleman::Base + include Middleman::Renderers::Less +end diff --git a/lib/middleman/sass.rb b/lib/middleman/renderers/sass.rb similarity index 100% rename from lib/middleman/sass.rb rename to lib/middleman/renderers/sass.rb diff --git a/middleman.gemspec b/middleman.gemspec index c9c03b46..0ba2964c 100644 --- a/middleman.gemspec +++ b/middleman.gemspec @@ -1,6 +1,6 @@ # Generated by jeweler -# DO NOT EDIT THIS FILE -# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec` +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command # -*- encoding: utf-8 -*- Gem::Specification.new do |s| @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Thomas Reynolds"] - s.date = %q{2010-06-09} + s.date = %q{2010-08-06} s.email = %q{tdreyno@gmail.com} s.executables = ["mm-init", "mm-build", "mm-server"] s.extra_rdoc_files = [ @@ -99,23 +99,23 @@ Gem::Specification.new do |s| s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] s.rubyforge_project = %q{middleman} - s.rubygems_version = %q{1.3.7} + s.rubygems_version = %q{1.3.6} s.summary = %q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting} s.test_files = [ - "spec/builder_spec.rb", - "spec/fixtures/sample/init.rb", + "spec/spec_helper.rb", + "spec/builder_spec.rb", "spec/helpers_spec.rb", - "spec/spec_helper.rb" + "spec/fixtures/sample/init.rb" ] if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION s.specification_version = 3 - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 0.8"]) s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 1.0"]) @@ -134,7 +134,7 @@ Gem::Specification.new do |s| else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0.8"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 1.0"]) @@ -154,7 +154,7 @@ Gem::Specification.new do |s| else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0.8"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 1.0"]) @@ -172,3 +172,4 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) end end +