ruhl 0.9.1 → 0.9.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.2
data/lib/ruhl.rb CHANGED
@@ -60,11 +60,19 @@ module Ruhl
60
60
  def render_collection(tag, code, actions = nil)
61
61
  results = execute_ruby(tag, code)
62
62
 
63
- tag['data-ruhl'] = actions if actions.to_s.strip.length > 0
64
- html = tag.to_html
63
+ actions = actions.to_s.strip
65
64
 
65
+ tag['data-ruhl'] = actions if actions.length > 0
66
+ html = tag.to_html
67
+
66
68
  new_content = results.collect do |item|
67
- Ruhl::Engine.new(html, :local_object => item).render(scope)
69
+ if actions.length == 0 && tag.children.length == 0
70
+ t = tag.dup
71
+ t.inner_html = item.to_s
72
+ t
73
+ else
74
+ Ruhl::Engine.new(html, :local_object => item).render(scope)
75
+ end
68
76
  end.to_s
69
77
 
70
78
  tag.swap(new_content)
@@ -161,7 +169,7 @@ module Ruhl
161
169
  end
162
170
  end
163
171
  else
164
- tag.inner_html = results
172
+ tag.inner_html = results.to_s
165
173
  end
166
174
  end
167
175
 
data/ruhl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruhl}
8
- s.version = "0.9.1"
8
+ s.version = "0.9.2"
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"]
12
- s.date = %q{2009-10-13}
12
+ s.date = %q{2009-10-15}
13
13
  s.description = %q{Make your HTML dynamic with the addition of a data-ruhl attribute.}
14
14
  s.email = %q{andy@stonean.com}
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "lib/ruhl/sinatra.rb",
27
27
  "ruhl.gemspec",
28
28
  "spec/html/basic.html",
29
+ "spec/html/collection_of_strings.html",
29
30
  "spec/html/form.html",
30
31
  "spec/html/fragment.html",
31
32
  "spec/html/hash.html",
@@ -37,6 +38,7 @@ Gem::Specification.new do |s|
37
38
  "spec/html/medium.html",
38
39
  "spec/html/seo.html",
39
40
  "spec/html/sidebar.html",
41
+ "spec/html/use.html",
40
42
  "spec/rcov.opts",
41
43
  "spec/ruhl_spec.rb",
42
44
  "spec/spec.opts",
@@ -0,0 +1,23 @@
1
+ <html>
2
+ <head>
3
+ <title>Hello World</title>
4
+ </head>
5
+ <body>
6
+ <h1>Ruby:</h1>
7
+ <ul>
8
+ <li data-ruhl="_collection: points_of_interest"></li>
9
+ </ul>
10
+
11
+ <h1>Ruby Titlized:</h1>
12
+ <ul>
13
+ <li data-ruhl="_collection: points_of_interest">
14
+ <span data-ruhl="capitalize"/>
15
+ </li>
16
+ </ul>
17
+
18
+ <h1>Ruby reversed:</h1>
19
+ <ul>
20
+ <li data-ruhl="_collection: points_of_interest, reverse"></li>
21
+ </ul>
22
+ </body>
23
+ </html>
@@ -0,0 +1,28 @@
1
+ <html>
2
+ <head>
3
+ <title>This is a title template</title>
4
+ </head>
5
+ <body>
6
+ <h1>My Account</h1>
7
+ <div id="sidebar" data-ruhl="_use: user">
8
+ <form action="/account" class="edit_user" id="edit_user" method="post">
9
+
10
+ <label for='user_first_name'>First Name:</label>
11
+ <input id="user_first_name" name="user[first_name]" size="30" type="text"
12
+ data-ruhl="value: first_name" />
13
+
14
+ <label for='user_last_name'>Last Name:</label>
15
+ <input id="user_last_name" name="user[last_name]" size="30" type="text"
16
+ data-ruhl="value: last_name" />
17
+
18
+ <label for='user_email'>Email:</label>
19
+ <input id="user_email" name="user[email]" size="30" type="text"
20
+ data-ruhl="value: email" />
21
+
22
+ <div class='btn_row'>
23
+ <input id="user_submit" name="commit" type="submit" value="Login" />
24
+ </div>
25
+ </form>
26
+ </div>
27
+ </body>
28
+ </html>
data/spec/ruhl_spec.rb CHANGED
@@ -171,7 +171,7 @@ describe Ruhl do
171
171
  @html = File.read html(:hash)
172
172
  end
173
173
 
174
- it "have radio inputsi with proper attributes" do
174
+ it "have radio inputs with proper attributes" do
175
175
  doc = create_doc
176
176
  nodes = doc.xpath('/html/body/label//input')
177
177
  nodes[0]['value'].should == 'doe'
@@ -201,6 +201,17 @@ describe Ruhl do
201
201
  @doc.xpath('/html/body/div//input')[2]['value'].should == "jane@stonean.com"
202
202
  end
203
203
  end
204
+
205
+ describe "collection_of_strings.html" do
206
+ before do
207
+ @html = File.read html(:collection_of_strings)
208
+ end
209
+
210
+ it "will have the string values in the li's" do
211
+ doc = create_doc
212
+ puts doc.to_s
213
+ end
214
+ end
204
215
  end
205
216
 
206
217
 
data/spec/spec_helper.rb CHANGED
@@ -141,3 +141,7 @@ class ContextObject
141
141
  end
142
142
 
143
143
  end
144
+
145
+ def points_of_interest
146
+ [ "Object oriented", "dynamic", "mixins", "blocks", "open source"]
147
+ end
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.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-13 00:00:00 -04:00
12
+ date: 2009-10-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -51,6 +51,7 @@ files:
51
51
  - lib/ruhl/sinatra.rb
52
52
  - ruhl.gemspec
53
53
  - spec/html/basic.html
54
+ - spec/html/collection_of_strings.html
54
55
  - spec/html/form.html
55
56
  - spec/html/fragment.html
56
57
  - spec/html/hash.html
@@ -62,6 +63,7 @@ files:
62
63
  - spec/html/medium.html
63
64
  - spec/html/seo.html
64
65
  - spec/html/sidebar.html
66
+ - spec/html/use.html
65
67
  - spec/rcov.opts
66
68
  - spec/ruhl_spec.rb
67
69
  - spec/spec.opts