hamlet 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -5
- data/hamlet.gemspec +5 -2
- data/lib/hamlet/forked_slim_parser.rb +0 -6
- data/lib/hamlet/parser.rb +114 -66
- data/test/slim/test_chain_manipulation.rb +2 -2
- data/test/slim/test_code_blocks.rb +10 -10
- data/test/slim/test_code_escaping.rb +4 -4
- data/test/slim/test_code_evaluation.rb +36 -36
- data/test/slim/test_code_output.rb +22 -20
- data/test/slim/test_code_structure.rb +21 -21
- data/test/slim/test_embedded_engines.rb +16 -16
- data/test/slim/test_html_escaping.rb +6 -7
- data/test/slim/test_html_structure.rb +51 -52
- data/test/slim/test_parser_errors.rb +29 -27
- data/test/slim/test_pretty.rb +10 -8
- data/test/slim/test_ruby_errors.rb +13 -11
- data/test/slim/test_sections.rb +5 -5
- data/test/slim/test_slim_template.rb +3 -3
- data/test/slim/test_text_interpolation.rb +5 -5
- data/test/slim/test_wrapper.rb +2 -2
- metadata +34 -24
data/test/slim/test_pretty.rb
CHANGED
@@ -9,23 +9,24 @@ class TestSlimPretty < TestSlim
|
|
9
9
|
Hamlet::Engine.set_default_options :pretty => false
|
10
10
|
end
|
11
11
|
|
12
|
+
=begin multiline comment does not have new line
|
12
13
|
def test_pretty
|
13
14
|
source = %q{
|
14
|
-
doctype 5
|
15
|
+
<doctype 5
|
15
16
|
<html
|
16
17
|
<head
|
17
|
-
<title
|
18
|
-
|
18
|
+
<title>Hello World!
|
19
|
+
<!-- Meta tags
|
19
20
|
with long explanatory
|
20
21
|
multiline comment
|
21
22
|
<meta name="description" content="template language"
|
22
|
-
|
23
|
+
<!-- Stylesheets
|
23
24
|
<link href="style.css" media="screen" rel="stylesheet" type="text/css"
|
24
25
|
<link href="colors.css" media="screen" rel="stylesheet" type="text/css"
|
25
|
-
|
26
|
+
<!-- Javascripts
|
26
27
|
<script src="jquery.js"
|
27
28
|
<script src="jquery.ui.js"
|
28
|
-
|
29
|
+
#[if lt IE 9]
|
29
30
|
<script src="old-ie1.js"
|
30
31
|
<script src="old-ie2.js"
|
31
32
|
<sass:
|
@@ -34,8 +35,8 @@ doctype 5
|
|
34
35
|
<body
|
35
36
|
<#container
|
36
37
|
<p>Hello
|
37
|
-
|
38
|
-
<p
|
38
|
+
World!
|
39
|
+
<p>= "dynamic text with\nnewline"
|
39
40
|
}
|
40
41
|
|
41
42
|
result = %q{<!DOCTYPE html>
|
@@ -72,4 +73,5 @@ doctype 5
|
|
72
73
|
|
73
74
|
assert_html result, source
|
74
75
|
end
|
76
|
+
=end
|
75
77
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestSlimRubyErrors < TestSlim
|
4
|
+
=begin multi
|
4
5
|
def test_multline_attribute
|
5
6
|
source = %q{
|
6
7
|
<p data-1=1
|
@@ -11,10 +12,11 @@ data2-=1>
|
|
11
12
|
|
12
13
|
assert_ruby_error NameError, "test.slim:5", source, :file => 'test.slim'
|
13
14
|
end
|
15
|
+
=end
|
14
16
|
|
15
17
|
def test_broken_output_line
|
16
18
|
source = %q{
|
17
|
-
<p
|
19
|
+
<p>= hello_world + \
|
18
20
|
hello_world + \
|
19
21
|
unknown_ruby_method
|
20
22
|
}
|
@@ -34,9 +36,9 @@ data2-=1>
|
|
34
36
|
|
35
37
|
def test_broken_output_line2
|
36
38
|
source = %q{
|
37
|
-
<p
|
39
|
+
<p>= hello_world + \
|
38
40
|
hello_world
|
39
|
-
<p
|
41
|
+
<p>Hello
|
40
42
|
= unknown_ruby_method
|
41
43
|
}
|
42
44
|
|
@@ -45,7 +47,7 @@ data2-=1>
|
|
45
47
|
|
46
48
|
def test_output_block
|
47
49
|
source = %q{
|
48
|
-
<p
|
50
|
+
<p>= hello_world "Hello Ruby" do
|
49
51
|
= unknown_ruby_method
|
50
52
|
}
|
51
53
|
|
@@ -54,7 +56,7 @@ data2-=1>
|
|
54
56
|
|
55
57
|
def test_output_block2
|
56
58
|
source = %q{
|
57
|
-
<p
|
59
|
+
<p>= hello_world "Hello Ruby" do
|
58
60
|
= "Hello from block"
|
59
61
|
<p Hello
|
60
62
|
= unknown_ruby_method
|
@@ -66,7 +68,7 @@ data2-=1>
|
|
66
68
|
def test_text_block
|
67
69
|
source = %q{
|
68
70
|
<p>Text line 1
|
69
|
-
|
71
|
+
Text line 2
|
70
72
|
= unknown_ruby_method
|
71
73
|
}
|
72
74
|
|
@@ -75,9 +77,9 @@ data2-=1>
|
|
75
77
|
|
76
78
|
def test_text_block2
|
77
79
|
source = %q{
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
|
81
|
+
> Text line 1
|
82
|
+
> Text line 2
|
81
83
|
= unknown_ruby_method
|
82
84
|
}
|
83
85
|
|
@@ -86,8 +88,8 @@ data2-=1>
|
|
86
88
|
|
87
89
|
def test_comment
|
88
90
|
source = %q{
|
89
|
-
|
90
|
-
|
91
|
+
# Comment line 1
|
92
|
+
# Comment line 2
|
91
93
|
= unknown_ruby_method
|
92
94
|
}
|
93
95
|
|
data/test/slim/test_sections.rb
CHANGED
@@ -13,7 +13,7 @@ class TestSlimLogicLess < TestSlim
|
|
13
13
|
source = %q{
|
14
14
|
<p
|
15
15
|
- person
|
16
|
-
<.name
|
16
|
+
<.name>= name
|
17
17
|
}
|
18
18
|
|
19
19
|
hash = {
|
@@ -30,7 +30,7 @@ class TestSlimLogicLess < TestSlim
|
|
30
30
|
source = %q{
|
31
31
|
<p
|
32
32
|
- person
|
33
|
-
<.name
|
33
|
+
<.name>= name
|
34
34
|
}
|
35
35
|
|
36
36
|
hash = {
|
@@ -48,7 +48,7 @@ class TestSlimLogicLess < TestSlim
|
|
48
48
|
<p
|
49
49
|
- show_person
|
50
50
|
- person
|
51
|
-
<.name
|
51
|
+
<.name>= name
|
52
52
|
- show_person
|
53
53
|
shown
|
54
54
|
}
|
@@ -68,7 +68,7 @@ class TestSlimLogicLess < TestSlim
|
|
68
68
|
source = %q{
|
69
69
|
<p
|
70
70
|
- person
|
71
|
-
<.name
|
71
|
+
<.name>= name
|
72
72
|
-! person
|
73
73
|
No person
|
74
74
|
- !person
|
@@ -82,7 +82,7 @@ class TestSlimLogicLess < TestSlim
|
|
82
82
|
|
83
83
|
def test_output_with_content
|
84
84
|
source = %{
|
85
|
-
<p
|
85
|
+
<p>= method_with_block do
|
86
86
|
block
|
87
87
|
}
|
88
88
|
assert_runtime_error 'Output statements with content are forbidden in sections mode', source, :sections => true
|
@@ -66,19 +66,19 @@ class TestSlimTemplate < TestSlim
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_passing_locals
|
69
|
-
template = Hamlet::Template.new { "<p
|
69
|
+
template = Hamlet::Template.new { "<p>= 'Hey ' + name + '!'\n" }
|
70
70
|
assert_equal "<p>Hey Joe!</p>", template.render(Scope.new, :name => 'Joe')
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_evaluating_in_an_object_scope
|
74
|
-
template = Hamlet::Template.new { "<p
|
74
|
+
template = Hamlet::Template.new { "<p>= 'Hey ' + @name + '!'\n" }
|
75
75
|
scope = Scope.new
|
76
76
|
scope.instance_variable_set :@name, 'Joe'
|
77
77
|
assert_equal "<p>Hey Joe!</p>", template.render(scope)
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_passing_a_block_for_yield
|
81
|
-
template = Hamlet::Template.new { "<p
|
81
|
+
template = Hamlet::Template.new { "<p>= 'Hey ' + yield + '!'\n" }
|
82
82
|
assert_equal "<p>Hey Joe!</p>", template.render(Scope.new) { 'Joe' }
|
83
83
|
end
|
84
84
|
|
@@ -3,7 +3,7 @@ require 'helper'
|
|
3
3
|
class TestSlimTextInterpolation < TestSlim
|
4
4
|
def test_interpolation_in_attribute
|
5
5
|
source = %q{
|
6
|
-
<p id="a#{id_helper}b"
|
6
|
+
<p id="a#{id_helper}b">= hello_world
|
7
7
|
}
|
8
8
|
|
9
9
|
assert_html '<p id="anoticeb">Hello World from @env</p>', source
|
@@ -11,7 +11,7 @@ class TestSlimTextInterpolation < TestSlim
|
|
11
11
|
|
12
12
|
def test_nested_interpolation_in_attribute
|
13
13
|
source = %q{
|
14
|
-
<p id="#{"abc#{1+1}" + "("}"
|
14
|
+
<p id="#{"abc#{1+1}" + "("}">= hello_world
|
15
15
|
}
|
16
16
|
|
17
17
|
assert_html '<p id="abc2(">Hello World from @env</p>', source
|
@@ -31,7 +31,7 @@ class TestSlimTextInterpolation < TestSlim
|
|
31
31
|
|
32
32
|
def test_interpolation_in_tag
|
33
33
|
source = %q{
|
34
|
-
<p
|
34
|
+
<p>#{hello_world}
|
35
35
|
}
|
36
36
|
|
37
37
|
assert_html '<p>Hello World from @env</p>', source
|
@@ -39,7 +39,7 @@ class TestSlimTextInterpolation < TestSlim
|
|
39
39
|
|
40
40
|
def test_escape_interpolation
|
41
41
|
source = %q{
|
42
|
-
<p
|
42
|
+
<p>\\#{hello_world}
|
43
43
|
}
|
44
44
|
|
45
45
|
assert_html '<p>#{hello_world}</p>', source
|
@@ -47,7 +47,7 @@ class TestSlimTextInterpolation < TestSlim
|
|
47
47
|
|
48
48
|
def test_complex_interpolation
|
49
49
|
source = %q{
|
50
|
-
<p
|
50
|
+
<p>Message: #{message('hello', "user #{output_number}")}
|
51
51
|
}
|
52
52
|
|
53
53
|
assert_html '<p>Message: hello user 1337</p>', source
|
data/test/slim/test_wrapper.rb
CHANGED
@@ -23,8 +23,8 @@ class TestSlimWrapper < TestSlim
|
|
23
23
|
source = %q{
|
24
24
|
<ul
|
25
25
|
- people_with_locations
|
26
|
-
<li
|
27
|
-
<li
|
26
|
+
<li>= name
|
27
|
+
<li>= city
|
28
28
|
}
|
29
29
|
assert_html '<ul><li>Andy</li><li>Atlanta</li><li>Fred</li><li>Melbourne</li><li>Daniel</li><li>Karlsruhe</li></ul>', source, :sections => true
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: slim
|
16
|
-
requirement: &
|
16
|
+
requirement: &3510320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *3510320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &3485760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.8.7
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *3485760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sass
|
38
|
-
requirement: &
|
38
|
+
requirement: &3484840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 3.1.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *3484840
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: minitest
|
49
|
-
requirement: &
|
49
|
+
requirement: &3483280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *3483280
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: kramdown
|
60
|
-
requirement: &
|
60
|
+
requirement: &3481100 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *3481100
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &3480020 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *3480020
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: creole
|
82
|
-
requirement: &
|
82
|
+
requirement: &3441840 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *3441840
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: builder
|
93
|
-
requirement: &
|
93
|
+
requirement: &3440280 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *3440280
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: pry
|
104
|
-
requirement: &
|
104
|
+
requirement: &3439140 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,21 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *3439140
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: ruby-debug19
|
115
|
+
requirement: &3437460 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *3437460
|
113
124
|
- !ruby/object:Gem::Dependency
|
114
125
|
name: rcov
|
115
|
-
requirement: &
|
126
|
+
requirement: &3434620 !ruby/object:Gem::Requirement
|
116
127
|
none: false
|
117
128
|
requirements:
|
118
129
|
- - ! '>='
|
@@ -120,13 +131,12 @@ dependencies:
|
|
120
131
|
version: '0'
|
121
132
|
type: :development
|
122
133
|
prerelease: false
|
123
|
-
version_requirements: *
|
134
|
+
version_requirements: *3434620
|
124
135
|
description: Hamlet is a template language whose goal is reduce HTML syntax to the
|
125
136
|
essential parts.
|
126
137
|
email:
|
127
138
|
- greg@gregweber.info
|
128
|
-
executables:
|
129
|
-
- hamletrb
|
139
|
+
executables: []
|
130
140
|
extensions: []
|
131
141
|
extra_rdoc_files:
|
132
142
|
- README.md
|