remove old haml table helper

This commit is contained in:
Thomas Reynolds 2011-07-10 13:34:53 -07:00
parent 859b7f6d97
commit 6cefa401f9
2 changed files with 48 additions and 65 deletions

View file

@ -6,36 +6,14 @@ module Middleman
module Haml
class << self
def registered(app)
app.helpers Middleman::Renderers::Haml::Helpers
app.helpers Helpers
end
alias :included :registered
end
module Helpers
def haml_partial(name, options = {})
partial(name, options)
end
end
module Table
include ::Haml::Filters::Base
def render(text)
output = '<div class="table"><table cellspacing="0" cellpadding="0">'
line_num = 0
text.each_line do |line|
line_num += 1
next if line.strip.empty?
output << %Q{<tr class="#{(line_num % 2 == 0) ? "even" : "odd" }#{(line_num == 1) ? " first" : "" }">}
columns = line.split("|").map { |p| p.strip }
columns.each_with_index do |col, i|
output << %Q{<td class="col#{i+1}">#{col}</td>}
end
output << "</tr>"
end
output + "</table></div>"
render(name, options)
end
end
end

View file

@ -9,17 +9,17 @@ module Middleman
class << self
def registered(app)
app.after_feature_init do
views_root = File.basename(self.views)
views_root = File.basename(app.views)
::Compass.configuration do |config|
config.cache = false # For sassc files
config.project_path = self.root
config.sass_dir = File.join(views_root, self.css_dir)
config.project_path = app.root
config.sass_dir = File.join(views_root, app.css_dir)
config.output_style = :nested
config.fonts_dir = File.join(views_root, self.fonts_dir)
config.css_dir = File.join(views_root, self.css_dir)
config.images_dir = File.join(views_root, self.images_dir)
config.http_images_path = self.http_images_path rescue File.join(self.http_prefix || "/", self.images_dir)
config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix || "/", self.css_dir)
config.fonts_dir = File.join(views_root, app.fonts_dir)
config.css_dir = File.join(views_root, app.css_dir)
config.images_dir = File.join(views_root, app.images_dir)
config.http_images_path = app.http_images_path rescue File.join(app.http_prefix || "/", app.images_dir)
config.http_stylesheets_path = app.http_css_path rescue File.join(app.http_prefix || "/", app.css_dir)
config.asset_cache_buster :none
config.add_import_path(config.sass_dir)
@ -36,11 +36,8 @@ module Middleman
end
alias :included :registered
end
end
end
end
class Tilt::SassPlusCSSFilenameTemplate < Tilt::SassTemplate
class SassPlusCSSFilenameTemplate < ::Tilt::SassTemplate
def sass_options
return super if basename.nil?
@ -62,22 +59,30 @@ class Tilt::SassPlusCSSFilenameTemplate < Tilt::SassTemplate
end
end
end
Tilt.register 'sass', Tilt::SassPlusCSSFilenameTemplate
::Tilt.register 'sass', SassPlusCSSFilenameTemplate
::Tilt.prefer(SassPlusCSSFilenameTemplate)
class Tilt::ScssPlusCSSFilenameTemplate < Tilt::SassPlusCSSFilenameTemplate
class ScssPlusCSSFilenameTemplate < SassPlusCSSFilenameTemplate
def sass_options
super.merge(:syntax => :scss)
end
end
Tilt.register 'scss', Tilt::ScssPlusCSSFilenameTemplate
::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
::Tilt.prefer(ScssPlusCSSFilenameTemplate)
end
end
end
# Use compass settings in Haml filters
# Other, tilt-based filters (like those used in Slim) will
# work automatically.
module Middleman::Renderers::Haml
module Sass
include ::Haml::Filters::Base
def render(text)
::Sass::Engine.new(text, ::Compass.configuration.to_sass_engine_options).render
compass_options = ::Compass.configuration.to_sass_engine_options
::Sass::Engine.new(text, compass_options).render
end
end
end