ruhl 0.9.0 → 0.9.1

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 CHANGED
@@ -370,6 +370,8 @@ if users? == false then the "No Users were found" message appears.
370
370
 
371
371
  The table row information will be replace with the current_user details.
372
372
 
373
+ *Note: _use can not be used with _partial as it replaces the inner_html
374
+
373
375
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374
376
  :: Notes ::
375
377
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
data/lib/ruhl.rb CHANGED
@@ -10,13 +10,14 @@ module Ruhl
10
10
 
11
11
  def initialize(html, options = {})
12
12
  @local_object = options[:local_object]
13
+ @block_object = options[:block_object]
13
14
  @layout_source = options[:layout_source]
14
15
 
15
16
  if @layout = options[:layout]
16
17
  raise LayoutNotFoundError.new(@layout) unless File.exists?(@layout)
17
18
  end
18
19
 
19
- if @layout || @local_object
20
+ if @layout || @local_object || @block_object
20
21
  @document = Nokogiri::HTML.fragment(html)
21
22
  else
22
23
  @document = Nokogiri::HTML(html)
@@ -69,6 +70,11 @@ module Ruhl
69
70
  tag.swap(new_content)
70
71
  end
71
72
 
73
+ def render_block(tag, code)
74
+ bo = execute_ruby(tag, code)
75
+ Ruhl::Engine.new(tag.inner_html, :block_object => bo).render(scope)
76
+ end
77
+
72
78
  def render_file(contents)
73
79
  doc = Nokogiri::HTML( contents )
74
80
  parse_doc(doc)
@@ -107,8 +113,7 @@ module Ruhl
107
113
  else
108
114
  case attribute
109
115
  when "_use"
110
- @block_object = execute_ruby(tag, value)
111
- @tag_block = tag
116
+ tag.inner_html = render_block(tag, value)
112
117
  when "_partial"
113
118
  tag.inner_html = render_partial(tag, value)
114
119
  when "_collection"
@@ -123,11 +128,6 @@ module Ruhl
123
128
  end
124
129
  end
125
130
  end
126
-
127
- if @tag_block == tag
128
- @tag_block = nil
129
- @block_object = nil
130
- end
131
131
  end
132
132
 
133
133
  def process_if(tag, value)
data/ruhl.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruhl}
8
- s.version = "0.9.0"
8
+ s.version = "0.9.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew Stone"]
data/spec/html/form.html CHANGED
@@ -1,4 +1,5 @@
1
- <form action="/account" class="edit_user" id="edit_user" method="post">
1
+ <form action="/account" class="edit_user" id="edit_user" method="post"
2
+ data-ruhl= "_use: user">
2
3
 
3
4
  <label for='user_first_name'>First Name:</label>
4
5
  <input id="user_first_name" name="user[first_name]" size="30" type="text"
@@ -4,7 +4,7 @@
4
4
  </head>
5
5
  <body>
6
6
  <h1>My Account</h1>
7
- <div id="sidebar" data-ruhl="_use: user, _partial: form_partial">
7
+ <div id="sidebar" data-ruhl="_partial: form_partial">
8
8
  <form action="/account" class="edit_user" id="edit_user" method="post">
9
9
 
10
10
  <label for='user_first_name'>First Name:</label>
data/spec/ruhl_spec.rb CHANGED
@@ -181,6 +181,26 @@ describe Ruhl do
181
181
  nodes[4]['value'].should == 'man'
182
182
  end
183
183
  end
184
+
185
+
186
+ describe "use.html" do
187
+ before do
188
+ @html = File.read html(:use)
189
+ @doc = create_doc
190
+ end
191
+
192
+ it "first name will be set" do
193
+ @doc.xpath('/html/body/div//input')[0]['value'].should == "Jane"
194
+ end
195
+
196
+ it "last name will be set" do
197
+ @doc.xpath('/html/body/div//input')[1]['value'].should == "Doe"
198
+ end
199
+
200
+ it "email will be set" do
201
+ @doc.xpath('/html/body/div//input')[2]['value'].should == "jane@stonean.com"
202
+ end
203
+ end
184
204
  end
185
205
 
186
206
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruhl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone