-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #528 from blambeau/wlang
Add support for wlang templating engine.
- Loading branch information
Showing
7 changed files
with
97 additions
and
0 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 @@ | ||
Hello from wlang! |
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 @@ | ||
WLang Layout! | ||
+{yield} |
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,70 @@ | ||
require File.expand_path('../helper', __FILE__) | ||
|
||
begin | ||
require 'wlang' | ||
|
||
class WLangTest < Test::Unit::TestCase | ||
def engine | ||
Tilt::WLangTemplate | ||
end | ||
|
||
def wlang_app(&block) | ||
mock_app { | ||
set :views, File.dirname(__FILE__) + '/views' | ||
get '/', &block | ||
} | ||
get '/' | ||
end | ||
|
||
it 'uses the correct engine' do | ||
assert_equal engine, Tilt[:wlang] | ||
end | ||
|
||
it 'renders .wlang files in views path' do | ||
wlang_app { wlang :hello } | ||
assert ok? | ||
assert_equal "Hello from wlang!\n", body | ||
end | ||
|
||
it 'renders in the app instance scope' do | ||
mock_app do | ||
helpers do | ||
def who; "world"; end | ||
end | ||
get('/') { wlang 'Hello +{who}!' } | ||
end | ||
get '/' | ||
assert ok? | ||
assert_equal 'Hello world!', body | ||
end | ||
|
||
it 'takes a :locals option' do | ||
wlang_app do | ||
locals = {:foo => 'Bar'} | ||
wlang 'Hello ${foo}!', :locals => locals | ||
end | ||
assert ok? | ||
assert_equal 'Hello Bar!', body | ||
end | ||
|
||
it "renders with inline layouts" do | ||
mock_app do | ||
layout { 'THIS. IS. +{yield.upcase}!' } | ||
get('/') { wlang 'Sparta' } | ||
end | ||
get '/' | ||
assert ok? | ||
assert_equal 'THIS. IS. SPARTA!', body | ||
end | ||
|
||
it "renders with file layouts" do | ||
wlang_app { wlang 'Hello World', :layout => :layout2 } | ||
assert ok? | ||
assert_body "WLang Layout!\nHello World" | ||
end | ||
|
||
end | ||
|
||
rescue LoadError | ||
warn "#{$!.to_s}: skipping wlang tests" | ||
end |