renshi 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/renshi/frameworks/rails.rb +22 -2
- data/lib/renshi.rb +1 -1
- data/spec/data/if_2.ren +0 -10
- data/spec/while_spec.rb +0 -2
- metadata +1 -1
@@ -1,7 +1,22 @@
|
|
1
1
|
module Renshi
|
2
2
|
module Frameworks
|
3
3
|
module Rails
|
4
|
-
if defined? ActionView::TemplateHandler
|
4
|
+
if defined? ActionView::TemplateHandler
|
5
|
+
class Plugin < ActionView::TemplateHandler
|
6
|
+
def self.call(template)
|
7
|
+
"#{name}.new(self).render(template, local_assigns)"
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(view = nil)
|
11
|
+
@view = view
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(template, local_assigns)
|
15
|
+
out = Renshi::Parser.parse(template.source, @view.renshi_binding)
|
16
|
+
return out
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
5
20
|
class CompilablePlugin
|
6
21
|
include ActionView::TemplateHandlers::Compilable
|
7
22
|
|
@@ -11,7 +26,6 @@ module Renshi
|
|
11
26
|
else
|
12
27
|
source = template
|
13
28
|
end
|
14
|
-
|
15
29
|
out = Renshi::Parser.parse(source)
|
16
30
|
return out
|
17
31
|
end
|
@@ -20,6 +34,12 @@ module Renshi
|
|
20
34
|
|
21
35
|
if defined? ActionView::TemplateHandler
|
22
36
|
ActionView::Template.register_template_handler(:ren, Renshi::Frameworks::Rails::CompilablePlugin)
|
37
|
+
|
38
|
+
class ActionView::Base
|
39
|
+
def renshi_binding
|
40
|
+
binding
|
41
|
+
end
|
42
|
+
end
|
23
43
|
end
|
24
44
|
end
|
25
45
|
end
|
data/lib/renshi.rb
CHANGED
data/spec/data/if_2.ren
CHANGED
data/spec/while_spec.rb
CHANGED