hamlet 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +28 -5
- data/hamlet.gemspec +1 -1
- data/lib/hamlet/parser.rb +1 -1
- data/test/slim/test_html_structure.rb +7 -7
- metadata +24 -24
data/README.md
CHANGED
@@ -33,7 +33,7 @@ This Hamlet works on top of [slim](https://github.com/stonean/slim/). Please tak
|
|
33
33
|
|
34
34
|
## Difference with Slim
|
35
35
|
|
36
|
-
The most important difference is that hamlet always uses angle brackets. Hamlet also does not require attributes to be quoted - unquoted is considered a normal html attribute value and quotes will be added. Hamlet also uses a '#' for code comments and the normal <!-- for HTML comments. Hamlet also uses different whitespace indicators - see the next section.
|
36
|
+
The most important difference is that hamlet always uses angle brackets. Hamlet also does not require attributes to be quoted - unquoted is considered a normal html attribute value and quotes will automatically be added. Hamlet also uses a '#' for code comments and the normal <!-- for HTML comments. Hamlet also uses different whitespace indicators - see the next section.
|
37
37
|
|
38
38
|
In Slim you have:
|
39
39
|
|
@@ -51,15 +51,38 @@ In hamlet you have:
|
|
51
51
|
|
52
52
|
## Whitespace
|
53
53
|
|
54
|
-
|
54
|
+
Using indentation does have some consequences with respect to white space. This library is designed to do the right thing most of the time. This is a slightly different design from the original Haskell implementation of Hamlet and Slim, but the same design as hamlet.js
|
55
55
|
|
56
|
-
|
57
|
-
|
56
|
+
A closing tag is placed immediately after the tag contents. If you want to have a space before a closing tag, use a comment sign `#` on the line to indicate where the end of the line is.
|
57
|
+
|
58
|
+
``` html
|
59
|
+
<b>spaces # 2 spaces are included
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
A new line is automatically added *after* tags with inner text. If you have multiple lines of inner text without tags (not a common use case) they will also get a new line added. If you do not want white space, you point it out with a `>` character, that you could think of as the end of the last tag, although you can still use it when separating content without tags onto different lines. You can also use a `>` if you want more than one space.
|
64
|
+
|
65
|
+
``` html
|
66
|
+
<b>spaces # 2 spaces are included
|
67
|
+
```
|
68
|
+
|
69
|
+
``` html
|
70
|
+
<b>spaces </b>
|
71
|
+
```
|
72
|
+
|
73
|
+
``` html
|
74
|
+
<b>no space
|
75
|
+
>none after bold.
|
76
|
+
> Two spaces after a period is bad!
|
77
|
+
```
|
78
|
+
|
79
|
+
``` html
|
80
|
+
<b>no space</b>none after bold. Two spaces after a period is bad!
|
58
81
|
|
59
82
|
|
60
83
|
## Limitations
|
61
84
|
|
62
|
-
I just hacked this up the other day - let me know if there are any issues.
|
85
|
+
I just hacked this up the other day - let me know if there are any issues.
|
63
86
|
|
64
87
|
## Development
|
65
88
|
|
data/hamlet.gemspec
CHANGED
data/lib/hamlet/parser.rb
CHANGED
@@ -107,7 +107,7 @@ class TestSlimHtmlStructure < TestSlim
|
|
107
107
|
<a href="link">page
|
108
108
|
}
|
109
109
|
|
110
|
-
assert_html "<p>this is
|
110
|
+
assert_html "<p>this is a link to\n<a href=\"link\">page</a></p>", source
|
111
111
|
end
|
112
112
|
|
113
113
|
def test_nested_text
|
@@ -120,7 +120,7 @@ class TestSlimHtmlStructure < TestSlim
|
|
120
120
|
<p>This is a new paragraph.
|
121
121
|
}
|
122
122
|
|
123
|
-
assert_html "<p>This is line one
|
123
|
+
assert_html "<p>This is line one. This is line two. This is line three. This is line four.</p>\n<p>This is a new paragraph.</p>", source
|
124
124
|
end
|
125
125
|
|
126
126
|
def test_nested_text_with_nested_html_one_same_line
|
@@ -132,7 +132,7 @@ class TestSlimHtmlStructure < TestSlim
|
|
132
132
|
> This is more content.
|
133
133
|
}
|
134
134
|
|
135
|
-
assert_html "<p>This is line one
|
135
|
+
assert_html "<p>This is line one. This is line two.\n<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
|
136
136
|
end
|
137
137
|
|
138
138
|
def test_nested_text_with_nested_html_one_same_line2
|
@@ -144,7 +144,7 @@ class TestSlimHtmlStructure < TestSlim
|
|
144
144
|
> This is more content.
|
145
145
|
}
|
146
146
|
|
147
|
-
assert_html "<p>This is line one
|
147
|
+
assert_html "<p>This is line one. This is line two.\n<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_nested_text_with_nested_html
|
@@ -157,7 +157,7 @@ class TestSlimHtmlStructure < TestSlim
|
|
157
157
|
> This is more content.
|
158
158
|
}
|
159
159
|
|
160
|
-
assert_html "<p>This is line one
|
160
|
+
assert_html "<p>This is line one. This is line two. This is line three. This is line four.\n<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
|
161
161
|
end
|
162
162
|
|
163
163
|
def test_simple_paragraph_with_padding
|
@@ -174,7 +174,7 @@ class TestSlimHtmlStructure < TestSlim
|
|
174
174
|
> This is line two.
|
175
175
|
}
|
176
176
|
|
177
|
-
assert_html "<p>This is line one
|
177
|
+
assert_html "<p>This is line one. This is line two.</p>", source
|
178
178
|
end
|
179
179
|
|
180
180
|
def test_paragraph_with_padded_nested_text
|
@@ -183,7 +183,7 @@ class TestSlimHtmlStructure < TestSlim
|
|
183
183
|
> This is line two.
|
184
184
|
}
|
185
185
|
|
186
|
-
assert_html "<p> This is line one
|
186
|
+
assert_html "<p> This is line one. This is line two.</p>", source
|
187
187
|
end
|
188
188
|
|
189
189
|
def test_paragraph_with_attributes_and_nested_text
|
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.
|
4
|
+
version: 0.4.1
|
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-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: slim
|
16
|
-
requirement: &
|
16
|
+
requirement: &3486060 !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: *3486060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &3484800 !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: *3484800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sass
|
38
|
-
requirement: &
|
38
|
+
requirement: &3482880 !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: *3482880
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: minitest
|
49
|
-
requirement: &
|
49
|
+
requirement: &3481440 !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: *3481440
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: kramdown
|
60
|
-
requirement: &
|
60
|
+
requirement: &3480460 !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: *3480460
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &3442220 !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: *3442220
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: creole
|
82
|
-
requirement: &
|
82
|
+
requirement: &3441000 !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: *3441000
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: builder
|
93
|
-
requirement: &
|
93
|
+
requirement: &3439960 !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: *3439960
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: pry
|
104
|
-
requirement: &
|
104
|
+
requirement: &3439320 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *3439320
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: ruby-debug19
|
115
|
-
requirement: &
|
115
|
+
requirement: &3438520 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *3438520
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rcov
|
126
|
-
requirement: &
|
126
|
+
requirement: &3435820 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *3435820
|
135
135
|
description: Hamlet is a template language whose goal is reduce HTML syntax to the
|
136
136
|
essential parts.
|
137
137
|
email:
|