remove markaby, enable maruku
This commit is contained in:
parent
2738e852f0
commit
85f336f65d
|
@ -28,7 +28,6 @@ module Middleman
|
||||||
disable :minify_css
|
disable :minify_css
|
||||||
disable :minify_javascript
|
disable :minify_javascript
|
||||||
disable :relative_assets
|
disable :relative_assets
|
||||||
disable :markaby
|
|
||||||
disable :maruku
|
disable :maruku
|
||||||
disable :smush_pngs
|
disable :smush_pngs
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
begin
|
|
||||||
require 'markaby'
|
|
||||||
rescue LoadError
|
|
||||||
puts "Markaby not available. Install it with: gem install markaby"
|
|
||||||
end
|
|
||||||
|
|
||||||
module Middleman
|
|
||||||
module Markaby
|
|
||||||
def self.included(base)
|
|
||||||
base.supported_formats << "mab"
|
|
||||||
end
|
|
||||||
|
|
||||||
def render_path(path)
|
|
||||||
if template_exists?(path, :mab)
|
|
||||||
markaby path.to_sym
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def markaby(template=nil, options={}, locals = {}, &block)
|
|
||||||
options, template = template, nil if template.is_a?(Hash)
|
|
||||||
template = lambda { block } if template.nil?
|
|
||||||
render :mab, template, options, locals
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
def render_mab(template, data, options, locals, &block)
|
|
||||||
filename = options.delete(:filename) || '<MARKABY>'
|
|
||||||
line = options.delete(:line) || 1
|
|
||||||
mab = ::Markaby::Builder.new(locals)
|
|
||||||
if data.respond_to?(:to_str)
|
|
||||||
eval(data.to_str, binding, filename, line)
|
|
||||||
elsif data.kind_of?(Proc)
|
|
||||||
data.call(mab)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Base
|
|
||||||
include Middleman::Markaby
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -8,23 +8,20 @@ module Middleman
|
||||||
module Maruku
|
module Maruku
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.supported_formats << "maruku"
|
base.supported_formats << "maruku"
|
||||||
|
base.set :maruku, {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_path(path)
|
def render_path(path)
|
||||||
if template_exists?(path, :maruku)
|
if template_exists?(path, :maruku)
|
||||||
maruku path.to_sym
|
render :maruku, path.to_sym
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def maruku(template, options={}, locals={})
|
|
||||||
render :maruku, template, options, locals
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def render_maruku(data, options, locals, &block)
|
def render_maruku(template, data, options, locals, &block)
|
||||||
maruku_src = render_erb(data, options, locals, &block)
|
maruku_src = render_erb(template, data, options, locals, &block)
|
||||||
instance = ::Maruku.new(maruku_src, options)
|
instance = ::Maruku.new(maruku_src, options)
|
||||||
if block_given?
|
if block_given?
|
||||||
# render layout
|
# render layout
|
||||||
|
|
|
@ -18,17 +18,12 @@ describe "Builder" do
|
||||||
FileUtils.rm_rf(File.join(@root_dir, "build"))
|
FileUtils.rm_rf(File.join(@root_dir, "build"))
|
||||||
end
|
end
|
||||||
|
|
||||||
xit "should build markaby files" do
|
|
||||||
File.exists?("#{@root_dir}/build/markaby.html").should be_true
|
|
||||||
File.read("#{@root_dir}/build/markaby.html").should include("<title>Hi Markaby</title>")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should build haml files" do
|
it "should build haml files" do
|
||||||
File.exists?("#{@root_dir}/build/index.html").should be_true
|
File.exists?("#{@root_dir}/build/index.html").should be_true
|
||||||
File.read("#{@root_dir}/build/index.html").should include("<h1>Welcome</h1>")
|
File.read("#{@root_dir}/build/index.html").should include("<h1>Welcome</h1>")
|
||||||
end
|
end
|
||||||
|
|
||||||
xit "should build maruku files" do
|
it "should build maruku files" do
|
||||||
File.exists?("#{@root_dir}/build/maruku.html").should be_true
|
File.exists?("#{@root_dir}/build/maruku.html").should be_true
|
||||||
File.read("#{@root_dir}/build/maruku.html").should include("<h1 class='header' id='hello_maruku'>Hello Maruku</h1>")
|
File.read("#{@root_dir}/build/maruku.html").should include("<h1 class='header' id='hello_maruku'>Hello Maruku</h1>")
|
||||||
end
|
end
|
||||||
|
|
3
spec/fixtures/sample/init.rb
vendored
3
spec/fixtures/sample/init.rb
vendored
|
@ -1,2 +1 @@
|
||||||
# enable :maruku
|
enable :maruku
|
||||||
# enable :markaby
|
|
5
spec/fixtures/sample/views/markaby.html.mab
vendored
5
spec/fixtures/sample/views/markaby.html.mab
vendored
|
@ -1,5 +0,0 @@
|
||||||
mab.html do
|
|
||||||
head do
|
|
||||||
title "Hi Markaby"
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue