renshi 0.0.6 → 0.0.7

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.
@@ -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
@@ -9,7 +9,7 @@ require 'renshi/attribute_expressions'
9
9
  require 'renshi/frameworks'
10
10
 
11
11
  module Renshi
12
- VERSION="0.0.6"
12
+ VERSION="0.0.7"
13
13
 
14
14
  class SyntaxError < StandardError; end
15
15
  end
data/spec/data/if_2.ren CHANGED
@@ -5,13 +5,3 @@
5
5
  </div>
6
6
  </body>
7
7
  </html>
8
-
9
-
10
- <html xmlns="http://www.w3.org/1999/xhtml">
11
- <body>
12
- <div id="content" r:each="foos, |foo|">
13
- hello
14
- </div>
15
- </body>
16
- </html>
17
-
data/spec/while_spec.rb CHANGED
@@ -9,7 +9,5 @@ describe Renshi::Parser do
9
9
  doc = N(out)
10
10
  (doc/"div[@id='content0']").text.strip.should =~ /hello0/
11
11
  (doc/"div[@id='content1']").text.strip.should =~ /hello1/
12
-
13
- puts doc
14
12
  end
15
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Faiz