utopia 0.9.47 → 0.9.48
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/lib/utopia/trenni.rb +11 -8
- data/lib/utopia/version.rb +1 -1
- metadata +4 -4
data/lib/utopia/trenni.rb
CHANGED
|
@@ -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
|
|
58
|
-
@callback.text(
|
|
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
|
-
|
|
66
|
+
level = 1
|
|
65
67
|
code = ""
|
|
66
68
|
|
|
67
|
-
until eos? ||
|
|
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(/\{
|
|
82
|
+
if scan(/\{/)
|
|
81
83
|
code << matched
|
|
84
|
+
level += 1
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
if scan(/\}/)
|
|
85
|
-
|
|
88
|
+
level -= 1
|
|
86
89
|
end
|
|
87
90
|
end
|
|
88
91
|
|
|
89
|
-
if
|
|
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
|
data/lib/utopia/version.rb
CHANGED
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:
|
|
4
|
+
hash: 91
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
|
-
-
|
|
10
|
-
version: 0.9.
|
|
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-
|
|
18
|
+
date: 2011-04-04 00:00:00 +12:00
|
|
19
19
|
default_executable: utopia
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|