markaby 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/{spec/spec.opts → .rspec} +0 -0
- data/Gemfile +8 -0
- data/Markaby.gemspec +20 -105
- data/README.rdoc +12 -94
- data/Rakefile +19 -50
- data/lib/markaby.rb +1 -5
- data/lib/markaby/builder.rb +15 -1
- data/lib/markaby/builder_tags.rb +22 -2
- data/lib/markaby/kernel_method.rb +1 -0
- data/lib/markaby/tags.rb +91 -2
- data/lib/markaby/version.rb +3 -0
- data/spec/markaby/{css_proxy_test.rb → css_proxy_spec.rb} +12 -17
- data/spec/markaby/{fragment_test.rb → fragment_spec.rb} +0 -0
- data/spec/markaby/html5_spec.rb +100 -0
- data/spec/markaby/markaby_spec.rb +1 -1
- data/spec/markaby/{markaby_test.rb → markaby_test_unit_spec.rb} +1 -1
- data/spec/spec_helper.rb +0 -5
- metadata +70 -76
- data/garlic.rb +0 -29
- data/init.rb +0 -6
- data/lib/markaby/rails.rb +0 -75
- data/lib/markaby/rails/current.rb +0 -85
- data/lib/markaby/rails/deprecated.rb +0 -124
- data/lib/markaby/rails/rails_builder.rb +0 -91
- data/lib/markaby/sinatra.rb +0 -18
- data/lib/markaby/tilt.rb +0 -8
- data/spec/markaby/markaby_other_static.mab +0 -1
- data/spec/markaby/rails/spec_helper.rb +0 -29
- data/spec/markaby/rails/views/layouts/layout.mab +0 -11
- data/spec/markaby/rails/views/markaby/_a_partial.mab +0 -3
- data/spec/markaby/rails/views/markaby/_form_for_with_body_in_erb.erb +0 -1
- data/spec/markaby/rails/views/markaby/_partial_child_with_locals.mab +0 -1
- data/spec/markaby/rails/views/markaby/access_to_helpers.mab +0 -1
- data/spec/markaby/rails/views/markaby/broken.mab +0 -7
- data/spec/markaby/rails/views/markaby/commented_out_template.mab +0 -1
- data/spec/markaby/rails/views/markaby/correct_template_values.mab +0 -5
- data/spec/markaby/rails/views/markaby/double_output.mab +0 -8
- data/spec/markaby/rails/views/markaby/form_for.mab +0 -2
- data/spec/markaby/rails/views/markaby/form_for_with_fields.mab +0 -3
- data/spec/markaby/rails/views/markaby/form_for_with_multiple_fields.mab +0 -4
- data/spec/markaby/rails/views/markaby/no_values_passed.mab +0 -3
- data/spec/markaby/rails/views/markaby/partial_parent.mab +0 -1
- data/spec/markaby/rails/views/markaby/partial_parent_with_locals.mab +0 -7
- data/spec/markaby/rails/views/markaby/render_erb_without_explicit_render_call.erb +0 -1
- data/spec/markaby/rails/views/markaby/render_explicit_but_empty_markaby_layout.mab +0 -0
- data/spec/markaby/rails/views/markaby/render_mab_without_explicit_render_call.mab +0 -3
- data/spec/markaby/rails/views/markaby/render_with_ivar.mab +0 -3
- data/spec/markaby/rails/views/markaby/renders_erb.rhtml +0 -1
- data/spec/markaby/rails/views/markaby/renders_form_for_with_erb_body.mab +0 -3
- data/spec/markaby/rails/views/markaby/routes.mab +0 -1
- data/spec/markaby/rails/views/markaby/yielding.mab +0 -3
- data/spec/markaby/rails/views/markaby/yielding_content_for_with_block_helper.mab +0 -5
- data/spec/markaby/rails/views/markaby/yielding_two.mab +0 -7
- data/spec/markaby/rails/views/markaby/yielding_with_content_for.mab +0 -3
- data/spec/markaby/rails_test.rb +0 -380
- data/spec/markaby/rails_version_spec.rb +0 -37
- data/spec/markaby/sinatra/app.rb +0 -49
- data/spec/markaby/sinatra/sinatra_spec.rb +0 -67
- data/spec/markaby/sinatra/views/helpers.mab +0 -1
- data/spec/markaby/sinatra/views/layout.mab +0 -7
- data/spec/markaby/sinatra/views/markaby_template.mab +0 -0
- data/spec/markaby/sinatra/views/scope_instance_variables.mab +0 -3
- data/spec/markaby/sinatra/views/simple_html.mab +0 -4
- data/spec/markaby/sinatra/views/variables.mab +0 -3
- data/spec/markaby/tilt/erb.erb +0 -1
- data/spec/markaby/tilt/locals.mab +0 -1
- data/spec/markaby/tilt/markaby.mab +0 -1
- data/spec/markaby/tilt/markaby_other_static.mab +0 -1
- data/spec/markaby/tilt/render_twice.mab +0 -1
- data/spec/markaby/tilt/scope.mab +0 -1
- data/spec/markaby/tilt/yielding.mab +0 -2
- data/spec/markaby/tilt_spec.rb +0 -75
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'rails', 'spec_helper')
|
2
|
-
|
3
|
-
unless RUNNING_RAILS
|
4
|
-
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
5
|
-
|
6
|
-
describe "when rails is loaded, but is not a supported version" do
|
7
|
-
module MockRails
|
8
|
-
module VERSION
|
9
|
-
STRING = ::Markaby::Rails::UNSUPPORTED_RAILS_VERSIONS.first
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def install_mock_rails
|
14
|
-
Object.const_set(:Rails, MockRails)
|
15
|
-
end
|
16
|
-
|
17
|
-
def remove_mock_rails
|
18
|
-
Object.class_eval do
|
19
|
-
remove_const(:Rails)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
before do
|
24
|
-
install_mock_rails
|
25
|
-
end
|
26
|
-
|
27
|
-
after do
|
28
|
-
remove_mock_rails
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should raise" do
|
32
|
-
lambda {
|
33
|
-
::Markaby::Rails.load
|
34
|
-
}.should raise_error(LoadError, "Cannot load markaby under rails version 2.0.0. See Markaby::Rails::SUPPORTED_RAILS_VERSIONS for exactly that, or redefine this constant.")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/spec/markaby/sinatra/app.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
set :views, lambda { File.join(File.dirname(__FILE__), "views") }
|
2
|
-
|
3
|
-
get '/empty_action' do
|
4
|
-
"hi there"
|
5
|
-
end
|
6
|
-
|
7
|
-
get '/markaby_template' do
|
8
|
-
mab :markaby_template
|
9
|
-
end
|
10
|
-
|
11
|
-
get '/simple_html' do
|
12
|
-
mab :simple_html
|
13
|
-
end
|
14
|
-
|
15
|
-
get '/variables' do
|
16
|
-
mab :variables, {}, :name => "Scott Taylor"
|
17
|
-
end
|
18
|
-
|
19
|
-
get '/variables_with_locals' do
|
20
|
-
mab :variables, :locals => { :name => "Scott Taylor" }
|
21
|
-
end
|
22
|
-
|
23
|
-
get '/scope_instance_variables' do
|
24
|
-
@name = "Scott Taylor"
|
25
|
-
mab :variables
|
26
|
-
end
|
27
|
-
|
28
|
-
template :layout_index do
|
29
|
-
'div.title "Hello World!"'
|
30
|
-
end
|
31
|
-
|
32
|
-
get "/named_template" do
|
33
|
-
mab :layout_index
|
34
|
-
end
|
35
|
-
|
36
|
-
get "/layout" do
|
37
|
-
@display_layout = true
|
38
|
-
mab :layout_index
|
39
|
-
end
|
40
|
-
|
41
|
-
helpers do
|
42
|
-
def chunky
|
43
|
-
"bacon"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
get "/helpers" do
|
48
|
-
mab :helpers
|
49
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
unless RUNNING_RAILS
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
3
|
-
require 'markaby/sinatra'
|
4
|
-
require 'rack/test'
|
5
|
-
require File.expand_path(File.dirname(__FILE__) + "/app")
|
6
|
-
|
7
|
-
describe "sinatra integration" do
|
8
|
-
include Rack::Test::Methods
|
9
|
-
|
10
|
-
def app
|
11
|
-
@app ||= Sinatra::Application
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should render an empty" do
|
15
|
-
get '/empty_action'
|
16
|
-
last_response.should be_ok
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should render an empty markaby template" do
|
20
|
-
get '/markaby_template'
|
21
|
-
last_response.should be_ok
|
22
|
-
last_response.body.should == ""
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should render a template with html in it" do
|
26
|
-
get '/simple_html'
|
27
|
-
last_response.should be_ok
|
28
|
-
last_response.body.should == "<ul><li>hi</li><li>there</li></ul>"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should be able to pass variables" do
|
32
|
-
get '/variables'
|
33
|
-
last_response.should be_ok
|
34
|
-
last_response.body.should == '<p class="name">Scott Taylor</p>'
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should be able to pass variables through locals" do
|
38
|
-
get '/variables_with_locals'
|
39
|
-
last_response.should be_ok
|
40
|
-
last_response.body.should == '<p class="name">Scott Taylor</p>'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should have scope to instance variables" do
|
44
|
-
get '/scope_instance_variables'
|
45
|
-
last_response.should be_ok
|
46
|
-
last_response.body.should == '<p class="name">Scott Taylor</p>'
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should be able to use named templates" do
|
50
|
-
get "/named_template"
|
51
|
-
last_response.should be_ok
|
52
|
-
last_response.body.should == '<div class="title">Hello World!</div>'
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should be able to use a layout with :layout" do
|
56
|
-
get '/layout'
|
57
|
-
last_response.should be_ok
|
58
|
-
last_response.body.should == '<html><div class="title">Hello World!</div></html>'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should be able to access helpers in a template" do
|
62
|
-
get '/helpers'
|
63
|
-
last_response.should be_ok
|
64
|
-
last_response.body.should == "<li>bacon</li>"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
li chunky
|
File without changes
|
data/spec/markaby/tilt/erb.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
hello from erb!
|
@@ -1 +0,0 @@
|
|
1
|
-
li foo
|
@@ -1 +0,0 @@
|
|
1
|
-
text "hello from markaby!"
|
@@ -1 +0,0 @@
|
|
1
|
-
text "_why?"
|
@@ -1 +0,0 @@
|
|
1
|
-
text "foo"
|
data/spec/markaby/tilt/scope.mab
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
li foo
|
data/spec/markaby/tilt_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
-
|
3
|
-
module Markaby
|
4
|
-
describe Tilt, "templates" do
|
5
|
-
before do
|
6
|
-
@block = lambda do |t|
|
7
|
-
File.read(File.dirname(__FILE__) + "/#{t.file}")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should have the constant ::Tilt::Markaby after registration" do
|
12
|
-
lambda {
|
13
|
-
::Tilt::MarkabyTemplate
|
14
|
-
}.should_not raise_error
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should be able to render an erb template" do
|
18
|
-
tilt = ::Tilt::ERBTemplate.new("tilt/erb.erb", &@block)
|
19
|
-
tilt.render.should == "hello from erb!"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should be able to render a markaby template with static html" do
|
23
|
-
tilt = ::Tilt::MarkabyTemplate.new("tilt/markaby.mab", &@block)
|
24
|
-
tilt.render.should == "hello from markaby!"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should use the contents of the template" do
|
28
|
-
tilt = ::Tilt::MarkabyTemplate.new("tilt/markaby_other_static.mab", &@block)
|
29
|
-
tilt.render.should == "_why?"
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should render from a string (given as data)" do
|
33
|
-
tilt = ::Tilt::MarkabyTemplate.new { "html do; end" }
|
34
|
-
tilt.render.should == "<html></html>"
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should evaluate a template file in the scope given" do
|
38
|
-
scope = mock 'scope object', :foo => "bar"
|
39
|
-
|
40
|
-
tilt = ::Tilt::MarkabyTemplate.new("tilt/scope.mab", &@block)
|
41
|
-
tilt.render(scope).should == "<li>bar</li>"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should pass locals to the template" do
|
45
|
-
tilt = ::Tilt::MarkabyTemplate.new("tilt/locals.mab", &@block)
|
46
|
-
tilt.render(Object.new, { :foo => "bar" }).should == "<li>bar</li>"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should yield to the block given" do
|
50
|
-
tilt = ::Tilt::MarkabyTemplate.new("tilt/yielding.mab", &@block)
|
51
|
-
eval_scope = Markaby::Builder.new
|
52
|
-
|
53
|
-
output = tilt.render(Object.new, {}) do
|
54
|
-
text("Joe")
|
55
|
-
end
|
56
|
-
|
57
|
-
output.should == "Hey Joe"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should be able to render two templates in a row" do
|
61
|
-
tilt = ::Tilt::MarkabyTemplate.new("tilt/render_twice.mab", &@block)
|
62
|
-
|
63
|
-
tilt.render.should == "foo"
|
64
|
-
tilt.render.should == "foo"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should retrieve a Tilt::MarkabyTemplate when calling Tilt['hello.mab']" do
|
68
|
-
::Tilt['./tilt/markaby.mab'].should == Markaby::Tilt::Template
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should return a new instance of the implementation class (when calling Tilt.new)" do
|
72
|
-
::Tilt.new(File.dirname(__FILE__) + "/tilt/markaby.mab").should be_a_kind_of(Markaby::Tilt::Template)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|