renshi 0.2.5 → 0.2.6
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 +5 -5
- data/lib/renshi/parser.rb +1 -1
- data/lib/renshi.rb +1 -1
- data/spec/parser_spec.rb +12 -11
- metadata +1 -1
data/README
CHANGED
@@ -17,16 +17,16 @@ e.g. or this
|
|
17
17
|
<p>$foo $bar</p>
|
18
18
|
|
19
19
|
|
20
|
-
${} delimits where the ruby begins and ends, for
|
20
|
+
${} delimits where the ruby begins and ends, for insertions within a line of HTML
|
21
21
|
|
22
22
|
e.g.
|
23
|
-
<p
|
23
|
+
<p>this is normal HTML but ${some_function "takes this string as input"} and now this is normal HTML</p>
|
24
24
|
|
25
|
-
|
25
|
+
$= is used for inplace insertion:
|
26
26
|
|
27
27
|
e.g.
|
28
|
-
<p>What are you doing up at
|
29
|
-
|
28
|
+
<p>What are you doing up at $=Time.now when you should be asleep?</p>
|
29
|
+
|
30
30
|
$[] allows ruby src code to be embedded. It's a bad practice (use helpers or something) but we let you do it.
|
31
31
|
|
32
32
|
$[if foo]
|
data/lib/renshi/parser.rb
CHANGED
@@ -140,7 +140,7 @@ module Renshi
|
|
140
140
|
rescue StandardError
|
141
141
|
raise SyntaxError, "No closing bracket: #{text}", caller
|
142
142
|
end
|
143
|
-
elsif next_char == "
|
143
|
+
elsif next_char == "=" #$=foo
|
144
144
|
#divide with a delimiter for anything which is not a name character - alpa-numeric and underscore
|
145
145
|
words = text[(idx + 2)..-1].split(/[^\w."'{}()+=*\/\-@\[\]:?!%]/)
|
146
146
|
words[0] = "'$'" if words[0] == "$"
|
data/lib/renshi.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -101,8 +101,8 @@ describe Renshi::Parser do
|
|
101
101
|
html.should =~/head/
|
102
102
|
end
|
103
103
|
|
104
|
-
it "should interpret single
|
105
|
-
raw = Renshi::Parser.parse("
|
104
|
+
it "should interpret single $=foos using \W, i.e. $=foo$=bar should render" do
|
105
|
+
raw = Renshi::Parser.parse("$=foo$=bar")
|
106
106
|
foo = "hello"
|
107
107
|
bar = " world"
|
108
108
|
|
@@ -110,6 +110,14 @@ describe Renshi::Parser do
|
|
110
110
|
|
111
111
|
html.should eql "hello world"
|
112
112
|
end
|
113
|
+
|
114
|
+
it "should interpret $a$b$c" do
|
115
|
+
a = 'a'; b = 'b'; c = 'c';
|
116
|
+
raw = Renshi::Parser.parse("$a$b$c")
|
117
|
+
html = eval(raw, binding)
|
118
|
+
|
119
|
+
html.should eql "abc"
|
120
|
+
end
|
113
121
|
|
114
122
|
class Test
|
115
123
|
def bar
|
@@ -198,13 +206,6 @@ end
|
|
198
206
|
html.should eql true.to_s
|
199
207
|
end
|
200
208
|
|
201
|
-
it "should interpret $a$b$c" do
|
202
|
-
a = 'a'; b = 'b'; c = 'c';
|
203
|
-
raw = Renshi::Parser.parse("$a$b$c")
|
204
|
-
html = eval(raw, binding)
|
205
|
-
|
206
|
-
html.should eql "abc"
|
207
|
-
end
|
208
209
|
|
209
210
|
it "should interpret $'foo'.upcase!" do
|
210
211
|
raw = Renshi::Parser.parse("$'foo'.upcase!")
|
@@ -237,8 +238,8 @@ end
|
|
237
238
|
html.should =~ /this should output as a string/
|
238
239
|
end
|
239
240
|
|
240
|
-
it "should interpret
|
241
|
-
raw = Renshi::Parser.parse("this should
|
241
|
+
it "should interpret $=foo as the single phrase" do
|
242
|
+
raw = Renshi::Parser.parse("this should $=foo 'hello'")
|
242
243
|
foo = "say"
|
243
244
|
html = eval(raw, binding)
|
244
245
|
|