Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add markaby helper method. Tilt supports Markaby for quite some time …
…now, but it was not as easy to use as haml or erb, and not documented. Tests and documentation (English and German) included.
- Loading branch information
Showing
8 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
h1 "Hello From Markaby" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require File.dirname(__FILE__) + '/helper' | ||
|
||
begin | ||
require 'markaby' | ||
|
||
class MarkabyTest < Test::Unit::TestCase | ||
def markaby_app(&block) | ||
mock_app do | ||
set :views, File.dirname(__FILE__) + '/views' | ||
get '/', &block | ||
end | ||
get '/' | ||
end | ||
|
||
it 'renders inline markaby strings' do | ||
markaby_app { markaby 'h1 "Hiya"' } | ||
assert ok? | ||
assert_equal "<h1>Hiya</h1>", body | ||
end | ||
|
||
it 'renders .markaby files in views path' do | ||
markaby_app { markaby :hello } | ||
assert ok? | ||
assert_equal "<h1>Hello From Markaby</h1>", body | ||
end | ||
|
||
it "renders with inline layouts" do | ||
mock_app do | ||
layout { 'h1 { text "THIS. IS. "; yield }' } | ||
get('/') { markaby 'em "SPARTA"' } | ||
end | ||
get '/' | ||
assert ok? | ||
assert_equal "<h1>THIS. IS. <em>SPARTA</em></h1>", body | ||
end | ||
|
||
it "renders with file layouts" do | ||
markaby_app { markaby 'text "Hello World"', :layout => :layout2 } | ||
assert ok? | ||
assert_equal "<h1>Markaby Layout!</h1><p>Hello World</p>", body | ||
end | ||
|
||
it "raises error if template not found" do | ||
mock_app { get('/') { markaby :no_such_template } } | ||
assert_raise(Errno::ENOENT) { get('/') } | ||
end | ||
|
||
it "allows passing locals" do | ||
markaby_app do | ||
markaby 'text value', :locals => { :value => 'foo' } | ||
end | ||
assert ok? | ||
assert_equal 'foo', body | ||
end | ||
end | ||
rescue | ||
warn "#{$!.to_s}: skipping markaby tests" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
h1 "Hello From Markaby" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1 "Markaby Layout!" | ||
p { yield } |