slim 0.9.1.alpha.2 → 0.9.1

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
@@ -55,7 +55,7 @@ Slim's syntax has been influenced by both _Haml_ and _Jade_.
55
55
 
56
56
  Here's a quick example to demonstrate what a Slim template looks like:
57
57
 
58
- ! doctype html
58
+ doctype html
59
59
  html
60
60
  head
61
61
  title Slim Examples
data/lib/slim/compiler.rb CHANGED
@@ -69,13 +69,13 @@ module Slim
69
69
  on_slim_output(escape, tmp, [:multi])]
70
70
  end
71
71
 
72
- # Handle directive expression `[:slim, :directive, type]`
72
+ # Handle directive expression `[:slim, :directive, type, args]`
73
73
  #
74
74
  # @param [String] type Directive type
75
75
  # @return [Array] Compiled temple expression
76
- def on_slim_directive(type)
77
- if type =~ /^doctype/i
78
- [:html, :doctype, $'.strip]
76
+ def on_slim_directive(type, args)
77
+ if type == 'doctype'
78
+ [:html, :doctype, args]
79
79
  end
80
80
  end
81
81
 
@@ -19,7 +19,7 @@ module Slim
19
19
  when /^#\{/
20
20
  # Interpolation
21
21
  string, code = parse_expression($')
22
- escape = code !~ Parser::DELIMITER_REGEX || Parser::DELIMITERS[$&] != code[-1, 1]
22
+ escape = code !~ /^\{.*\}$/
23
23
  block << [:slim, :output, escape, escape ? code : code[1..-2], [:multi]]
24
24
  when /^([^#]+|#)/
25
25
  # Static text
data/lib/slim/parser.rb CHANGED
@@ -42,7 +42,7 @@ module Slim
42
42
  # Since you can indent however you like in Slim, we need to keep a list
43
43
  # of how deeply indented you are. For instance, in a template like this:
44
44
  #
45
- # ! doctype # 0 spaces
45
+ # doctype # 0 spaces
46
46
  # html # 0 spaces
47
47
  # head # 1 space
48
48
  # title # 4 spaces
@@ -205,7 +205,8 @@ module Slim
205
205
  stacks << block
206
206
  when ?!
207
207
  # Found a directive (currently only used for doctypes)
208
- stacks.last << [:slim, :directive, line[1..-1].strip]
208
+ directive = line[1..-1].strip.split(/\s+/, 2)
209
+ stacks.last << [:slim, :directive, directive[0].downcase, directive[1]]
209
210
  else
210
211
  if line =~ /^(\w+):\s*$/
211
212
  # Embedded template detected. It is treated as block.
@@ -214,6 +215,8 @@ module Slim
214
215
  stacks << block
215
216
  block_indent = indent
216
217
  next
218
+ elsif line =~ /^doctype\s+/i
219
+ stacks.last << [:slim, :directive, 'doctype', $'.strip]
217
220
  else
218
221
  # Found a HTML tag.
219
222
  tag, block, broken_line, text_indent = parse_tag(line, lineno)
data/lib/slim/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slim
2
- VERSION = '0.9.1.alpha.2'
2
+ VERSION = '0.9.1'
3
3
  end
@@ -1,4 +1,4 @@
1
- ! doctype html
1
+ doctype html
2
2
 
3
3
  html
4
4
  head
@@ -25,11 +25,29 @@ html:body
25
25
 
26
26
  def test_doctype
27
27
  source = %q{
28
- ! doctype 5
28
+ ! doctype 1.1
29
29
  html
30
30
  }
31
31
 
32
- assert_html '<!DOCTYPE html><html></html>', source
32
+ assert_html '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html></html>', source, :format => :xhtml
33
+ end
34
+
35
+ def test_doctype_new_syntax
36
+ source = %q{
37
+ doctype 5
38
+ html
39
+ }
40
+
41
+ assert_html '<!DOCTYPE html><html></html>', source, :format => :xhtml
42
+ end
43
+
44
+ def test_doctype_new_syntax_html5
45
+ source = %q{
46
+ doctype html
47
+ html
48
+ }
49
+
50
+ assert_html '<!DOCTYPE html><html></html>', source, :format => :xhtml
33
51
  end
34
52
 
35
53
  def test_capitalized_doctype
@@ -53,4 +53,11 @@ p Message: #{message('hello', "user #{output_number}")}
53
53
 
54
54
  assert_html '<script>do_something_evil();</script>', source
55
55
  end
56
+
57
+ def test_interpolation_with_escaping_and_delimiter
58
+ source = %q{
59
+ | #{(evil_method)}
60
+ }
61
+ assert_html '&lt;script&gt;do_something_evil();&lt;&#47;script&gt;', source
62
+ end
56
63
  end
metadata CHANGED
@@ -1,14 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ prerelease: false
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
8
  - 1
9
- - alpha
10
- - 2
11
- version: 0.9.1.alpha.2
9
+ version: 0.9.1
12
10
  platform: ruby
13
11
  authors:
14
12
  - Andrew Stone
@@ -18,7 +16,7 @@ autorequire:
18
16
  bindir: bin
19
17
  cert_chain: []
20
18
 
21
- date: 2011-02-03 00:00:00 +11:00
19
+ date: 2011-03-10 00:00:00 -05:00
22
20
  default_executable:
23
21
  dependencies:
24
22
  - !ruby/object:Gem::Dependency
@@ -32,8 +30,8 @@ dependencies:
32
30
  segments:
33
31
  - 0
34
32
  - 1
35
- - 7
36
- version: 0.1.7
33
+ - 8
34
+ version: 0.1.8
37
35
  type: :runtime
38
36
  version_requirements: *id001
39
37
  - !ruby/object:Gem::Dependency
@@ -250,13 +248,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
248
  required_rubygems_version: !ruby/object:Gem::Requirement
251
249
  none: false
252
250
  requirements:
253
- - - ">"
251
+ - - ">="
254
252
  - !ruby/object:Gem::Version
255
253
  segments:
256
- - 1
257
- - 3
258
- - 1
259
- version: 1.3.1
254
+ - 0
255
+ version: "0"
260
256
  requirements: []
261
257
 
262
258
  rubyforge_project: slim