slim 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -108,7 +108,7 @@ Here's a quick example to demonstrate what a Slim template looks like:
108
108
 
109
109
  #### `==`
110
110
 
111
- > Same as the single equal sign, but does not go through the escape_html method.
111
+ > Same as the single equal sign, but does not go through the `escape_html` method.
112
112
 
113
113
  #### `!`
114
114
 
@@ -118,6 +118,11 @@ Here's a quick example to demonstrate what a Slim template looks like:
118
118
 
119
119
  > Use the forward slash for ruby code comments - anything after it won't get displayed in the final render.
120
120
 
121
+ #### `/!`
122
+
123
+ > Use the forward slash immediately followed by an exclamation mark for html comments (`<!-- -->`).
124
+
125
+
121
126
  ### Things to know
122
127
 
123
128
  #### Standard Ruby syntax after `-` and `=`
@@ -253,18 +258,19 @@ Here's a quick example to demonstrate what a Slim template looks like:
253
258
  This line will have two spaces in front of it.
254
259
  And so on...
255
260
 
256
- ### Add code comments
261
+ ### Add comments
257
262
 
258
- Use a forward slash for ruby code comments
263
+ Use `/` for ruby code comments and `/!` for html comments
259
264
 
260
265
  body
261
266
  p
262
267
  / This line won't get displayed.
263
268
  Neither does this line.
269
+ /! This will get displayed as html comments.
264
270
 
265
271
  The parsed result of the above:
266
272
 
267
- <body><p></p></body>
273
+ <body><p><!--This will get displayed as html comments.--></p></body>
268
274
 
269
275
  ### Validate Slim syntax
270
276
 
data/lib/slim/parser.rb CHANGED
@@ -69,7 +69,7 @@ module Slim
69
69
  # Hello
70
70
  # World!
71
71
  #
72
- block_indent, in_comment, text_indent = nil, false, nil
72
+ block_indent, in_slim_comment, in_html_comment, text_indent = nil, false, false, nil
73
73
 
74
74
  str.each_line do |line|
75
75
  lineno += 1
@@ -104,10 +104,10 @@ module Slim
104
104
  # Handle blocks with multiple lines
105
105
  if block_indent
106
106
  if indent > block_indent
107
- # This line happens to be indented deeper (or equal) than the block start character (|, ', `, /).
107
+ # This line happens to be indented deeper (or equal) than the block start character (|, ', /).
108
108
  # This means that it's a part of the block.
109
109
 
110
- if !in_comment
110
+ if !in_slim_comment
111
111
  # The indentation of first line of the text block determines the text base indentation.
112
112
  newline = text_indent ? "\n" : ''
113
113
  text_indent ||= indent
@@ -124,10 +124,15 @@ module Slim
124
124
  next
125
125
  end
126
126
 
127
+ # Closes the html comment
128
+ if in_html_comment
129
+ stacks.last << [:static, '-->']
130
+ end
131
+
127
132
  # It's guaranteed that we're now *not* in a block, because
128
133
  # the indent was less than the block start indent.
129
134
  block_indent = text_indent = nil
130
- in_comment = false
135
+ in_slim_comment = in_html_comment = false
131
136
  end
132
137
 
133
138
  # If there's more stacks than indents, it means that the previous
@@ -173,9 +178,16 @@ module Slim
173
178
  stacks << block
174
179
  block_indent = indent
175
180
 
176
- in_comment = line[0] == ?/
181
+ in_slim_comment = line[0] == ?/ && line[1] != ?!
182
+ in_html_comment = line[0] == ?/ && line[1] == ?! && line.slice!(0)
177
183
  line.slice!(0)
178
- if !in_comment && !line.strip.empty?
184
+
185
+ # We're entering a block of html comments, so let's add an opening tag
186
+ if in_html_comment
187
+ block << [:static, '<!--']
188
+ end
189
+
190
+ if !in_slim_comment && !line.strip.empty?
179
191
  block << [:slim, :text, line.sub(/^( )/, '')]
180
192
  text_indent = block_indent + ($1 ? 2 : 1)
181
193
  end
data/lib/slim/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slim
2
- VERSION = '0.8.2'
2
+ VERSION = '0.8.3'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 2
9
- version: 0.8.2
8
+ - 3
9
+ version: 0.8.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Stone
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-22 00:00:00 -05:00
19
+ date: 2010-12-23 00:00:00 +11:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency