tilt 1.4.1 → 2.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +1 -1
- data/bin/tilt +18 -8
- data/lib/tilt/asciidoc.rb +1 -8
- data/lib/tilt/babel.rb +16 -0
- data/lib/tilt/bluecloth.rb +24 -0
- data/lib/tilt/builder.rb +12 -15
- data/lib/tilt/coffee.rb +10 -6
- data/lib/tilt/commonmarker.rb +88 -0
- data/lib/tilt/creole.rb +25 -0
- data/lib/tilt/csv.rb +12 -18
- data/lib/tilt/dummy.rb +3 -0
- data/lib/tilt/erb.rb +9 -56
- data/lib/tilt/erubi.rb +32 -0
- data/lib/tilt/erubis.rb +43 -0
- data/lib/tilt/haml.rb +66 -44
- data/lib/tilt/kramdown.rb +25 -0
- data/lib/tilt/less.rb +30 -0
- data/lib/tilt/liquid.rb +9 -10
- data/lib/tilt/livescript.rb +23 -0
- data/lib/tilt/mapping.rb +293 -0
- data/lib/tilt/markaby.rb +1 -8
- data/lib/tilt/maruku.rb +22 -0
- data/lib/tilt/nokogiri.rb +1 -8
- data/lib/tilt/pandoc.rb +57 -0
- data/lib/tilt/plain.rb +0 -4
- data/lib/tilt/prawn.rb +43 -0
- data/lib/tilt/radius.rb +1 -8
- data/lib/tilt/rdiscount.rb +39 -0
- data/lib/tilt/rdoc.rb +3 -10
- data/lib/tilt/redcarpet.rb +86 -0
- data/lib/tilt/{textile.rb → redcloth.rb} +1 -8
- data/lib/tilt/rst-pandoc.rb +23 -0
- data/lib/tilt/sass.rb +78 -0
- data/lib/tilt/sigil.rb +34 -0
- data/lib/tilt/string.rb +1 -1
- data/lib/tilt/template.rb +121 -105
- data/lib/tilt/typescript.rb +26 -0
- data/lib/tilt/wikicloth.rb +22 -0
- data/lib/tilt/yajl.rb +1 -8
- data/lib/tilt.rb +118 -155
- metadata +38 -469
- data/CHANGELOG.md +0 -44
- data/Gemfile +0 -32
- data/HACKING +0 -16
- data/README.md +0 -232
- data/Rakefile +0 -104
- data/TEMPLATES.md +0 -516
- data/lib/tilt/css.rb +0 -80
- data/lib/tilt/markdown.rb +0 -214
- data/lib/tilt/wiki.rb +0 -58
- data/test/contest.rb +0 -68
- data/test/markaby/locals.mab +0 -1
- data/test/markaby/markaby.mab +0 -1
- data/test/markaby/markaby_other_static.mab +0 -1
- data/test/markaby/render_twice.mab +0 -1
- data/test/markaby/scope.mab +0 -1
- data/test/markaby/yielding.mab +0 -2
- data/test/tilt_asciidoctor_test.rb +0 -44
- data/test/tilt_blueclothtemplate_test.rb +0 -45
- data/test/tilt_buildertemplate_test.rb +0 -59
- data/test/tilt_cache_test.rb +0 -32
- data/test/tilt_coffeescripttemplate_test.rb +0 -114
- data/test/tilt_compilesite_test.rb +0 -51
- data/test/tilt_creoletemplate_test.rb +0 -28
- data/test/tilt_csv_test.rb +0 -69
- data/test/tilt_erbtemplate_test.rb +0 -239
- data/test/tilt_erubistemplate_test.rb +0 -151
- data/test/tilt_etannitemplate_test.rb +0 -173
- data/test/tilt_fallback_test.rb +0 -122
- data/test/tilt_hamltemplate_test.rb +0 -144
- data/test/tilt_kramdown_test.rb +0 -42
- data/test/tilt_lesstemplate_test.less +0 -1
- data/test/tilt_lesstemplate_test.rb +0 -42
- data/test/tilt_liquidtemplate_test.rb +0 -78
- data/test/tilt_markaby_test.rb +0 -88
- data/test/tilt_markdown_test.rb +0 -172
- data/test/tilt_marukutemplate_test.rb +0 -48
- data/test/tilt_nokogiritemplate_test.rb +0 -87
- data/test/tilt_radiustemplate_test.rb +0 -75
- data/test/tilt_rdiscounttemplate_test.rb +0 -55
- data/test/tilt_rdoctemplate_test.rb +0 -31
- data/test/tilt_redcarpettemplate_test.rb +0 -71
- data/test/tilt_redclothtemplate_test.rb +0 -36
- data/test/tilt_sasstemplate_test.rb +0 -41
- data/test/tilt_stringtemplate_test.rb +0 -170
- data/test/tilt_template_test.rb +0 -323
- data/test/tilt_test.rb +0 -65
- data/test/tilt_wikiclothtemplate_test.rb +0 -32
- data/test/tilt_yajltemplate_test.rb +0 -101
- data/tilt.gemspec +0 -120
data/test/tilt_markdown_test.rb
DELETED
@@ -1,172 +0,0 @@
|
|
1
|
-
# coding: UTF-8
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'nokogiri'
|
6
|
-
|
7
|
-
module MarkdownTests
|
8
|
-
def self.included(mod)
|
9
|
-
class << mod
|
10
|
-
def template(t = nil)
|
11
|
-
t.nil? ? @template : @template = t
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def render(text, options = {})
|
17
|
-
self.class.template.new(options) { text }.render
|
18
|
-
end
|
19
|
-
|
20
|
-
def normalize(html)
|
21
|
-
Nokogiri::HTML.fragment(html).to_s.strip
|
22
|
-
end
|
23
|
-
|
24
|
-
def nrender(text, options = {})
|
25
|
-
html = render(text, options)
|
26
|
-
html.encode!("UTF-8") if html.respond_to?(:encode)
|
27
|
-
normalize(html)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_escape_html
|
31
|
-
html = nrender "Hello <b>World</b>"
|
32
|
-
assert_equal "<p>Hello <b>World</b></p>", html
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_escape_html_false
|
36
|
-
html = nrender "Hello <b>World</b>", :escape_html => false
|
37
|
-
assert_equal "<p>Hello <b>World</b></p>", html
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_escape_html_true
|
41
|
-
if self.class.template == Tilt::RedcarpetTemplate
|
42
|
-
flunk "redcarpet doesn't support :escape_html yet"
|
43
|
-
end
|
44
|
-
html = nrender "Hello <b>World</b>", :escape_html => true
|
45
|
-
assert_equal "<p>Hello <b>World</b></p>", html
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_smart_quotes
|
49
|
-
html = nrender 'Hello "World"'
|
50
|
-
assert_equal '<p>Hello "World"</p>', html
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_smart_quotes_false
|
54
|
-
html = nrender 'Hello "World"', :smartypants => false
|
55
|
-
assert_equal '<p>Hello "World"</p>', html
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_smart_quotes_true
|
59
|
-
html = nrender 'Hello "World"', :smartypants => true
|
60
|
-
assert_equal '<p>Hello “World”</p>', html
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_smarty_pants
|
64
|
-
html = nrender "Hello ``World'' -- This is --- a test ..."
|
65
|
-
assert_equal "<p>Hello ``World'' -- This is --- a test ...</p>", html
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_smarty_pants_false
|
69
|
-
html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => false
|
70
|
-
assert_equal "<p>Hello ``World'' -- This is --- a test ...</p>", html
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_smarty_pants_true
|
74
|
-
html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => true
|
75
|
-
assert_equal "<p>Hello “World” — This is —– a test …</p>", html
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
begin
|
80
|
-
require 'rdiscount'
|
81
|
-
|
82
|
-
class MarkdownRDiscountTest < Test::Unit::TestCase
|
83
|
-
include MarkdownTests
|
84
|
-
template Tilt::RDiscountTemplate
|
85
|
-
end
|
86
|
-
rescue LoadError => boom
|
87
|
-
# It should already be warned in the main tests
|
88
|
-
end
|
89
|
-
|
90
|
-
begin
|
91
|
-
require 'redcarpet'
|
92
|
-
|
93
|
-
class MarkdownRedcarpetTest < Test::Unit::TestCase
|
94
|
-
include MarkdownTests
|
95
|
-
template Tilt::RedcarpetTemplate
|
96
|
-
# Doesn't support escaping
|
97
|
-
undef test_escape_html_true
|
98
|
-
|
99
|
-
def test_smarty_pants_true
|
100
|
-
html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => true
|
101
|
-
assert_equal "<p>Hello “World'' – This is — a test …</p>", html
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_fenced_code_blocks_with_lang
|
105
|
-
code = <<-COD.gsub(/^\s+/,"")
|
106
|
-
```ruby
|
107
|
-
puts "hello world"
|
108
|
-
```
|
109
|
-
COD
|
110
|
-
|
111
|
-
html = nrender code, :fenced_code_blocks => true
|
112
|
-
assert_equal %Q{<pre><code class="ruby">puts "hello world"\n</code></pre>}, html
|
113
|
-
end
|
114
|
-
end
|
115
|
-
rescue LoadError => boom
|
116
|
-
# It should already be warned in the main tests
|
117
|
-
end
|
118
|
-
|
119
|
-
begin
|
120
|
-
require 'bluecloth'
|
121
|
-
|
122
|
-
class MarkdownBlueClothTest < Test::Unit::TestCase
|
123
|
-
include MarkdownTests
|
124
|
-
template Tilt::BlueClothTemplate
|
125
|
-
end
|
126
|
-
rescue LoadError => boom
|
127
|
-
# It should already be warned in the main tests
|
128
|
-
end
|
129
|
-
|
130
|
-
begin
|
131
|
-
require 'kramdown'
|
132
|
-
|
133
|
-
class MarkdownKramdownTest < Test::Unit::TestCase
|
134
|
-
include MarkdownTests
|
135
|
-
template Tilt::KramdownTemplate
|
136
|
-
# Doesn't support escaping
|
137
|
-
undef test_escape_html_true
|
138
|
-
# Smarty Pants is *always* on, but doesn't support it fully
|
139
|
-
undef test_smarty_pants
|
140
|
-
undef test_smarty_pants_false
|
141
|
-
undef test_smarty_pants_true
|
142
|
-
end
|
143
|
-
rescue LoadError => boom
|
144
|
-
# It should already be warned in the main tests
|
145
|
-
end
|
146
|
-
|
147
|
-
|
148
|
-
begin
|
149
|
-
require 'maruku'
|
150
|
-
|
151
|
-
class MarkdownMarukuTest < Test::Unit::TestCase
|
152
|
-
include MarkdownTests
|
153
|
-
template Tilt::MarukuTemplate
|
154
|
-
# Doesn't support escaping
|
155
|
-
undef test_escape_html_true
|
156
|
-
# Doesn't support Smarty Pants, and even fails on ``Foobar''
|
157
|
-
undef test_smarty_pants
|
158
|
-
undef test_smarty_pants_false
|
159
|
-
undef test_smarty_pants_true
|
160
|
-
# Smart Quotes is always on
|
161
|
-
undef test_smart_quotes
|
162
|
-
undef test_smart_quotes_false
|
163
|
-
end
|
164
|
-
rescue LoadError => boom
|
165
|
-
# It should already be warned in the main tests
|
166
|
-
end
|
167
|
-
|
168
|
-
rescue LoadError
|
169
|
-
warn "Markdown tests need Nokogiri"
|
170
|
-
end
|
171
|
-
|
172
|
-
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'maruku'
|
6
|
-
|
7
|
-
class MarukuTemplateTest < Test::Unit::TestCase
|
8
|
-
test "registered for '.md' files" do
|
9
|
-
assert Tilt.mappings['md'].include?(Tilt::MarukuTemplate)
|
10
|
-
end
|
11
|
-
|
12
|
-
test "registered for '.mkd' files" do
|
13
|
-
assert Tilt.mappings['mkd'].include?(Tilt::MarukuTemplate)
|
14
|
-
end
|
15
|
-
|
16
|
-
test "registered for '.markdown' files" do
|
17
|
-
assert Tilt.mappings['markdown'].include?(Tilt::MarukuTemplate)
|
18
|
-
end
|
19
|
-
|
20
|
-
test "registered below Kramdown" do
|
21
|
-
%w[md mkd markdown].each do |ext|
|
22
|
-
mappings = Tilt.mappings[ext]
|
23
|
-
kram_idx = mappings.index(Tilt::KramdownTemplate)
|
24
|
-
maru_idx = mappings.index(Tilt::MarukuTemplate)
|
25
|
-
assert maru_idx > kram_idx,
|
26
|
-
"#{maru_idx} should be higher than #{kram_idx}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
test "preparing and evaluating templates on #render" do
|
31
|
-
template = Tilt::MarukuTemplate.new { |t| "# Hello World!" }
|
32
|
-
assert_equal "<h1 id='hello_world'>Hello World!</h1>", template.render
|
33
|
-
end
|
34
|
-
|
35
|
-
test "can be rendered more than once" do
|
36
|
-
template = Tilt::MarukuTemplate.new { |t| "# Hello World!" }
|
37
|
-
3.times { assert_equal "<h1 id='hello_world'>Hello World!</h1>", template.render }
|
38
|
-
end
|
39
|
-
|
40
|
-
test "removes HTML when :filter_html is set" do
|
41
|
-
template = Tilt::MarukuTemplate.new(:filter_html => true) { |t|
|
42
|
-
"HELLO <blink>WORLD</blink>" }
|
43
|
-
assert_equal "<p>HELLO </p>", template.render
|
44
|
-
end
|
45
|
-
end
|
46
|
-
rescue LoadError => boom
|
47
|
-
warn "Tilt::MarukuTemplate (disabled)"
|
48
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'nokogiri'
|
6
|
-
class NokogiriTemplateTest < Test::Unit::TestCase
|
7
|
-
test "registered for '.nokogiri' files" do
|
8
|
-
assert_equal Tilt::NokogiriTemplate, Tilt['test.nokogiri']
|
9
|
-
assert_equal Tilt::NokogiriTemplate, Tilt['test.xml.nokogiri']
|
10
|
-
end
|
11
|
-
|
12
|
-
test "preparing and evaluating the template on #render" do
|
13
|
-
template = Tilt::NokogiriTemplate.new { |t| "xml.em 'Hello World!'" }
|
14
|
-
doc = Nokogiri.XML template.render
|
15
|
-
assert_equal 'Hello World!', doc.root.text
|
16
|
-
assert_equal 'em', doc.root.name
|
17
|
-
end
|
18
|
-
|
19
|
-
test "can be rendered more than once" do
|
20
|
-
template = Tilt::NokogiriTemplate.new { |t| "xml.em 'Hello World!'" }
|
21
|
-
3.times do
|
22
|
-
doc = Nokogiri.XML template.render
|
23
|
-
assert_equal 'Hello World!', doc.root.text
|
24
|
-
assert_equal 'em', doc.root.name
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
test "passing locals" do
|
29
|
-
template = Tilt::NokogiriTemplate.new { "xml.em('Hey ' + name + '!')" }
|
30
|
-
doc = Nokogiri.XML template.render(Object.new, :name => 'Joe')
|
31
|
-
assert_equal 'Hey Joe!', doc.root.text
|
32
|
-
assert_equal 'em', doc.root.name
|
33
|
-
end
|
34
|
-
|
35
|
-
test "evaluating in an object scope" do
|
36
|
-
template = Tilt::NokogiriTemplate.new { "xml.em('Hey ' + @name + '!')" }
|
37
|
-
scope = Object.new
|
38
|
-
scope.instance_variable_set :@name, 'Joe'
|
39
|
-
doc = Nokogiri.XML template.render(scope)
|
40
|
-
assert_equal 'Hey Joe!', doc.root.text
|
41
|
-
assert_equal 'em', doc.root.name
|
42
|
-
end
|
43
|
-
|
44
|
-
test "passing a block for yield" do
|
45
|
-
template = Tilt::NokogiriTemplate.new { "xml.em('Hey ' + yield + '!')" }
|
46
|
-
3.times do
|
47
|
-
doc = Nokogiri.XML template.render { 'Joe' }
|
48
|
-
assert_equal 'Hey Joe!', doc.root.text
|
49
|
-
assert_equal 'em', doc.root.name
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
test "block style templates" do
|
54
|
-
template =
|
55
|
-
Tilt::NokogiriTemplate.new do |t|
|
56
|
-
lambda { |xml| xml.em('Hey Joe!') }
|
57
|
-
end
|
58
|
-
doc = Nokogiri.XML template.render
|
59
|
-
assert_equal 'Hey Joe!', doc.root.text
|
60
|
-
assert_equal 'em', doc.root.name
|
61
|
-
end
|
62
|
-
|
63
|
-
test "allows nesting raw XML, API-compatible to Builder" do
|
64
|
-
subtemplate = Tilt::NokogiriTemplate.new { "xml.em 'Hello World!'" }
|
65
|
-
template = Tilt::NokogiriTemplate.new { "xml.strong { xml << yield }" }
|
66
|
-
3.times do
|
67
|
-
options = { :xml => Nokogiri::XML::Builder.new }
|
68
|
-
doc = Nokogiri.XML(template.render(options) { subtemplate.render(options) })
|
69
|
-
assert_equal 'Hello World!', doc.root.text.strip
|
70
|
-
assert_equal 'strong', doc.root.name
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
test "doesn't modify self when template is a string" do
|
75
|
-
template = Tilt::NokogiriTemplate.new { "xml.root { xml.child @hello }" }
|
76
|
-
scope = Object.new
|
77
|
-
scope.instance_variable_set(:@hello, "Hello World!")
|
78
|
-
|
79
|
-
3.times do
|
80
|
-
doc = Nokogiri.XML(template.render(scope))
|
81
|
-
assert_equal "Hello World!", doc.text.strip
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
rescue LoadError
|
86
|
-
warn "Tilt::NokogiriTemplate (disabled)"
|
87
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'radius'
|
6
|
-
|
7
|
-
# Disable radius tests under Ruby versions >= 1.9.1 since it's still buggy.
|
8
|
-
# Remove when fixed upstream.
|
9
|
-
raise LoadError if RUBY_VERSION >= "1.9.1" and Radius.version < "0.7"
|
10
|
-
|
11
|
-
class RadiusTemplateTest < Test::Unit::TestCase
|
12
|
-
test "registered for '.radius' files" do
|
13
|
-
assert_equal Tilt::RadiusTemplate, Tilt['test.radius']
|
14
|
-
end
|
15
|
-
|
16
|
-
test "preparing and evaluating templates on #render" do
|
17
|
-
template = Tilt::RadiusTemplate.new { |t| "Hello World!" }
|
18
|
-
assert_equal "Hello World!", template.render
|
19
|
-
end
|
20
|
-
|
21
|
-
test "can be rendered more than once" do
|
22
|
-
template = Tilt::RadiusTemplate.new { |t| "Hello World!" }
|
23
|
-
3.times { assert_equal "Hello World!", template.render }
|
24
|
-
end
|
25
|
-
|
26
|
-
test "passing locals" do
|
27
|
-
template = Tilt::RadiusTemplate.new { "Hey <r:name />!" }
|
28
|
-
assert_equal "Hey Joe!", template.render(nil, :name => 'Joe')
|
29
|
-
end
|
30
|
-
|
31
|
-
class ExampleRadiusScope
|
32
|
-
def beer; 'wet'; end
|
33
|
-
def whisky; 'wetter'; end
|
34
|
-
end
|
35
|
-
|
36
|
-
test "combining scope and locals when scope responds" do
|
37
|
-
template = Tilt::RadiusTemplate.new {
|
38
|
-
'Beer is <r:beer /> but Whisky is <r:whisky />.'
|
39
|
-
}
|
40
|
-
scope = ExampleRadiusScope.new
|
41
|
-
assert_equal "Beer is wet but Whisky is wetter.", template.render(scope)
|
42
|
-
end
|
43
|
-
|
44
|
-
test "precedence when locals and scope define same variables" do
|
45
|
-
template = Tilt::RadiusTemplate.new {
|
46
|
-
'Beer is <r:beer /> but Whisky is <r:whisky />.'
|
47
|
-
}
|
48
|
-
scope = ExampleRadiusScope.new
|
49
|
-
assert_equal "Beer is great but Whisky is greater.",
|
50
|
-
template.render(scope, :beer => 'great', :whisky => 'greater')
|
51
|
-
end
|
52
|
-
|
53
|
-
#test "handles local scope" do
|
54
|
-
# beer = 'wet'
|
55
|
-
# whisky = 'wetter'
|
56
|
-
#
|
57
|
-
# template = Tilt::RadiusTemplate.new {
|
58
|
-
# 'Beer is <r:beer /> but Whisky is <r:whisky />.'
|
59
|
-
# }
|
60
|
-
# assert_equal "Beer is wet but Whisky is wetter.", template.render(self)
|
61
|
-
#end
|
62
|
-
|
63
|
-
test "passing a block for yield" do
|
64
|
-
template = Tilt::RadiusTemplate.new {
|
65
|
-
'Beer is <r:yield /> but Whisky is <r:yield />ter.'
|
66
|
-
}
|
67
|
-
assert_equal "Beer is wet but Whisky is wetter.",
|
68
|
-
template.render({}) { 'wet' }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
rescue LoadError => boom
|
73
|
-
warn "Tilt::RadiusTemplate (disabled)"
|
74
|
-
end
|
75
|
-
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rdiscount'
|
6
|
-
|
7
|
-
class RDiscountTemplateTest < Test::Unit::TestCase
|
8
|
-
test "registered for '.md' files" do
|
9
|
-
assert Tilt.mappings['md'].include?(Tilt::RDiscountTemplate)
|
10
|
-
end
|
11
|
-
|
12
|
-
test "registered for '.mkd' files" do
|
13
|
-
assert Tilt.mappings['mkd'].include?(Tilt::RDiscountTemplate)
|
14
|
-
end
|
15
|
-
|
16
|
-
test "registered for '.markdown' files" do
|
17
|
-
assert Tilt.mappings['markdown'].include?(Tilt::RDiscountTemplate)
|
18
|
-
end
|
19
|
-
|
20
|
-
test "registered above BlueCloth" do
|
21
|
-
%w[md mkd markdown].each do |ext|
|
22
|
-
mappings = Tilt.mappings[ext]
|
23
|
-
blue_idx = mappings.index(Tilt::BlueClothTemplate)
|
24
|
-
rdis_idx = mappings.index(Tilt::RDiscountTemplate)
|
25
|
-
assert rdis_idx < blue_idx,
|
26
|
-
"#{rdis_idx} should be lower than #{blue_idx}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
test "preparing and evaluating templates on #render" do
|
31
|
-
template = Tilt::RDiscountTemplate.new { |t| "# Hello World!" }
|
32
|
-
assert_equal "<h1>Hello World!</h1>\n", template.render
|
33
|
-
end
|
34
|
-
|
35
|
-
test "can be rendered more than once" do
|
36
|
-
template = Tilt::RDiscountTemplate.new { |t| "# Hello World!" }
|
37
|
-
3.times { assert_equal "<h1>Hello World!</h1>\n", template.render }
|
38
|
-
end
|
39
|
-
|
40
|
-
test "smartypants when :smart is set" do
|
41
|
-
template = Tilt::RDiscountTemplate.new(:smart => true) { |t|
|
42
|
-
"OKAY -- 'Smarty Pants'" }
|
43
|
-
assert_equal "<p>OKAY — ‘Smarty Pants’</p>\n",
|
44
|
-
template.render
|
45
|
-
end
|
46
|
-
|
47
|
-
test "stripping HTML when :filter_html is set" do
|
48
|
-
template = Tilt::RDiscountTemplate.new(:filter_html => true) { |t|
|
49
|
-
"HELLO <blink>WORLD</blink>" }
|
50
|
-
assert_equal "<p>HELLO <blink>WORLD</blink></p>\n", template.render
|
51
|
-
end
|
52
|
-
end
|
53
|
-
rescue LoadError => boom
|
54
|
-
warn "Tilt::RDiscountTemplate (disabled)"
|
55
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rdoc'
|
6
|
-
require 'rdoc/markup'
|
7
|
-
require 'rdoc/markup/to_html'
|
8
|
-
class RDocTemplateTest < Test::Unit::TestCase
|
9
|
-
test "is registered for '.rdoc' files" do
|
10
|
-
assert_equal Tilt::RDocTemplate, Tilt['test.rdoc']
|
11
|
-
end
|
12
|
-
|
13
|
-
test "preparing and evaluating the template with #render" do
|
14
|
-
template = Tilt::RDocTemplate.new { |t| "= Hello World!" }
|
15
|
-
result = template.render.strip
|
16
|
-
assert_match /<h1/, result
|
17
|
-
assert_match />Hello World!</, result
|
18
|
-
end
|
19
|
-
|
20
|
-
test "can be rendered more than once" do
|
21
|
-
template = Tilt::RDocTemplate.new { |t| "= Hello World!" }
|
22
|
-
3.times do
|
23
|
-
result = template.render.strip
|
24
|
-
assert_match /<h1/, result
|
25
|
-
assert_match />Hello World!</, result
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
rescue LoadError => boom
|
30
|
-
warn "Tilt::RDocTemplate (disabled) [#{boom}]"
|
31
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'redcarpet'
|
6
|
-
|
7
|
-
class RedcarpetTemplateTest < Test::Unit::TestCase
|
8
|
-
test "registered for '.md' files" do
|
9
|
-
assert Tilt.mappings['md'].include?(Tilt::RedcarpetTemplate)
|
10
|
-
end
|
11
|
-
|
12
|
-
test "registered for '.mkd' files" do
|
13
|
-
assert Tilt.mappings['mkd'].include?(Tilt::RedcarpetTemplate)
|
14
|
-
end
|
15
|
-
|
16
|
-
test "registered for '.markdown' files" do
|
17
|
-
assert Tilt.mappings['markdown'].include?(Tilt::RedcarpetTemplate)
|
18
|
-
end
|
19
|
-
|
20
|
-
test "registered above BlueCloth" do
|
21
|
-
%w[md mkd markdown].each do |ext|
|
22
|
-
mappings = Tilt.mappings[ext]
|
23
|
-
blue_idx = mappings.index(Tilt::BlueClothTemplate)
|
24
|
-
redc_idx = mappings.index(Tilt::RedcarpetTemplate)
|
25
|
-
assert redc_idx < blue_idx,
|
26
|
-
"#{redc_idx} should be lower than #{blue_idx}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
test "registered above RDiscount" do
|
31
|
-
%w[md mkd markdown].each do |ext|
|
32
|
-
mappings = Tilt.mappings[ext]
|
33
|
-
rdis_idx = mappings.index(Tilt::RDiscountTemplate)
|
34
|
-
redc_idx = mappings.index(Tilt::RedcarpetTemplate)
|
35
|
-
assert redc_idx < rdis_idx,
|
36
|
-
"#{redc_idx} should be lower than #{rdis_idx}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
test "redcarpet2 is our default choice" do
|
41
|
-
template = Tilt::RedcarpetTemplate.new {}
|
42
|
-
assert_equal Tilt::RedcarpetTemplate::Redcarpet2, template.prepare.class
|
43
|
-
end
|
44
|
-
|
45
|
-
test "preparing and evaluating templates on #render" do
|
46
|
-
template = Tilt::RedcarpetTemplate.new { |t| "# Hello World!" }
|
47
|
-
assert_equal "<h1>Hello World!</h1>\n", template.render
|
48
|
-
end
|
49
|
-
|
50
|
-
test "can be rendered more than once" do
|
51
|
-
template = Tilt::RedcarpetTemplate.new { |t| "# Hello World!" }
|
52
|
-
3.times { assert_equal "<h1>Hello World!</h1>\n", template.render }
|
53
|
-
end
|
54
|
-
|
55
|
-
test "smartypants when :smart is set" do
|
56
|
-
template = Tilt::RedcarpetTemplate.new(:smartypants => true) { |t|
|
57
|
-
"OKAY -- 'Smarty Pants'" }
|
58
|
-
assert_match /<p>OKAY – 'Smarty Pants'<\/p>/,
|
59
|
-
template.render
|
60
|
-
end
|
61
|
-
|
62
|
-
test "smartypants with a rendererer instance" do
|
63
|
-
template = Tilt::RedcarpetTemplate.new(:renderer => Redcarpet::Render::HTML.new(:hard_wrap => true), :smartypants => true) { |t|
|
64
|
-
"OKAY -- 'Smarty Pants'" }
|
65
|
-
assert_match /<p>OKAY – 'Smarty Pants'<\/p>/,
|
66
|
-
template.render
|
67
|
-
end
|
68
|
-
end
|
69
|
-
rescue LoadError => boom
|
70
|
-
warn "Tilt::RedcarpetTemplate (disabled)"
|
71
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'redcloth'
|
6
|
-
|
7
|
-
class RedClothTemplateTest < Test::Unit::TestCase
|
8
|
-
test "is registered for '.textile' files" do
|
9
|
-
assert_equal Tilt::RedClothTemplate, Tilt['test.textile']
|
10
|
-
end
|
11
|
-
|
12
|
-
test "compiles and evaluates the template on #render" do
|
13
|
-
template = Tilt::RedClothTemplate.new { |t| "h1. Hello World!" }
|
14
|
-
assert_equal "<h1>Hello World!</h1>", template.render
|
15
|
-
end
|
16
|
-
|
17
|
-
test "can be rendered more than once" do
|
18
|
-
template = Tilt::RedClothTemplate.new { |t| "h1. Hello World!" }
|
19
|
-
3.times { assert_equal "<h1>Hello World!</h1>", template.render }
|
20
|
-
end
|
21
|
-
|
22
|
-
test "ignores unknown options" do
|
23
|
-
template = Tilt::RedClothTemplate.new(:foo => "bar") { |t| "h1. Hello World!" }
|
24
|
-
3.times { assert_equal "<h1>Hello World!</h1>", template.render }
|
25
|
-
end
|
26
|
-
|
27
|
-
test "passes in RedCloth options" do
|
28
|
-
template = Tilt::RedClothTemplate.new { |t| "Hard breaks are\ninserted by default." }
|
29
|
-
assert_equal "<p>Hard breaks are<br />\ninserted by default.</p>", template.render
|
30
|
-
template = Tilt::RedClothTemplate.new(:hard_breaks => false) { |t| "But they can be\nturned off." }
|
31
|
-
assert_equal "<p>But they can be\nturned off.</p>", template.render
|
32
|
-
end
|
33
|
-
end
|
34
|
-
rescue LoadError => boom
|
35
|
-
warn "Tilt::RedClothTemplate (disabled)"
|
36
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'contest'
|
2
|
-
require 'tilt'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'sass'
|
6
|
-
|
7
|
-
class SassTemplateTest < Test::Unit::TestCase
|
8
|
-
test "is registered for '.sass' files" do
|
9
|
-
assert_equal Tilt::SassTemplate, Tilt['test.sass']
|
10
|
-
end
|
11
|
-
|
12
|
-
test "compiles and evaluates the template on #render" do
|
13
|
-
template = Tilt::SassTemplate.new { |t| "#main\n :background-color #0000f1" }
|
14
|
-
assert_equal "#main {\n background-color: #0000f1; }\n", template.render
|
15
|
-
end
|
16
|
-
|
17
|
-
test "can be rendered more than once" do
|
18
|
-
template = Tilt::SassTemplate.new { |t| "#main\n :background-color #0000f1" }
|
19
|
-
3.times { assert_equal "#main {\n background-color: #0000f1; }\n", template.render }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class ScssTemplateTest < Test::Unit::TestCase
|
24
|
-
test "is registered for '.scss' files" do
|
25
|
-
assert_equal Tilt::ScssTemplate, Tilt['test.scss']
|
26
|
-
end
|
27
|
-
|
28
|
-
test "compiles and evaluates the template on #render" do
|
29
|
-
template = Tilt::ScssTemplate.new { |t| "#main {\n background-color: #0000f1;\n}" }
|
30
|
-
assert_equal "#main {\n background-color: #0000f1; }\n", template.render
|
31
|
-
end
|
32
|
-
|
33
|
-
test "can be rendered more than once" do
|
34
|
-
template = Tilt::ScssTemplate.new { |t| "#main {\n background-color: #0000f1;\n}" }
|
35
|
-
3.times { assert_equal "#main {\n background-color: #0000f1; }\n", template.render }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
rescue LoadError => boom
|
40
|
-
warn "Tilt::SassTemplate (disabled)"
|
41
|
-
end
|