utopia 0.9.47 → 0.9.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,6 +35,8 @@ module Utopia
35
35
  end
36
36
 
37
37
  class Scanner < StringScanner
38
+ TEXT = /([^<#]|<(?!\?r)|#[^\{]){1,1024}/m
39
+
38
40
  def initialize(callback, string)
39
41
  @callback = callback
40
42
  super(string)
@@ -54,17 +56,17 @@ module Utopia
54
56
  end
55
57
 
56
58
  def scan_text
57
- if scan_until(/(.*?)(?=\#\{|<\?r)/m) || scan(/(.*)\Z/m)
58
- @callback.text(self[1]) if self[1].size > 0
59
+ if scan(TEXT)
60
+ @callback.text(matched)
59
61
  end
60
62
  end
61
63
 
62
64
  def scan_expression
63
65
  if scan(/\#\{/)
64
- done = false
66
+ level = 1
65
67
  code = ""
66
68
 
67
- until eos? || done
69
+ until eos? || level == 0
68
70
  if scan(/[^"'\{\}]+/m)
69
71
  code << matched
70
72
  end
@@ -77,16 +79,17 @@ module Utopia
77
79
  code << matched
78
80
  end
79
81
 
80
- if scan(/\{[^\}]*\}/m)
82
+ if scan(/\{/)
81
83
  code << matched
84
+ level += 1
82
85
  end
83
86
 
84
87
  if scan(/\}/)
85
- done = true
88
+ level -= 1
86
89
  end
87
90
  end
88
91
 
89
- if done
92
+ if level == 0
90
93
  @callback.output(code)
91
94
  else
92
95
  raise StandardError.new "Could not find end of expression #{self}!"
@@ -114,7 +117,7 @@ module Utopia
114
117
  def compile!(filename = @filename)
115
118
  buffer = Buffer.new
116
119
  scanner = Scanner.new(buffer, @template)
117
-
120
+
118
121
  scanner.parse
119
122
 
120
123
  @code = buffer.code
@@ -6,7 +6,7 @@ module Utopia
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 9
9
- TINY = 47
9
+ TINY = 48
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia
3
3
  version: !ruby/object:Gem::Version
4
- hash: 101
4
+ hash: 91
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 47
10
- version: 0.9.47
9
+ - 48
10
+ version: 0.9.48
11
11
  platform: ruby
12
12
  authors:
13
13
  - Samuel Williams
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-31 00:00:00 +13:00
18
+ date: 2011-04-04 00:00:00 +12:00
19
19
  default_executable: utopia
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency