Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ActiveSupport::SafeBuffer objects are now automatically treated as ra…

…w in the Rails integration
  • Loading branch information...
commit f711d2bad53ae3e44d976223498a195f196cbdbe 1 parent 15dec61
Jeremy Evans authored December 11, 2012
4  CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+=== HEAD
  2
+
  3
+* ActiveSupport::SafeBuffer objects are now automatically treated as raw in the Rails integration (jeremyevans)
  4
+
1 5
 === 0.7.0 (2012-05-02)
2 6
 
3 7
 * Support :label_position option in both of the labelers, can be set to :before or :after to override the default (jeremyevans)
4  lib/forme/rails.rb
... ...
@@ -1,5 +1,9 @@
1 1
 require 'forme'
2 2
 
  3
+class ActiveSupport::SafeBuffer
  4
+  include Forme::Raw
  5
+end
  6
+
3 7
 module Forme
4 8
   module Rails # :nodoc:
5 9
     # Subclass used when using Forme/Rails ERB integration,
8  spec/rails_integration_spec.rb
@@ -139,6 +139,10 @@ def combined
139 139
   def noblock
140 140
     render :inline => "<%= forme([:foo, :bar], {:action=>'/baz'}, :inputs=>[:first], :button=>'xyz', :legend=>'123') %>"
141 141
   end
  142
+
  143
+  def safe_buffer
  144
+    render :inline => "<%= forme([:foo, :bar], {:action=>'/baz'}, :inputs=>[:first], :button=>'xyz', :legend=>'<b>foo</b>'.html_safe) %>"
  145
+  end
142 146
 end
143 147
 
144 148
 describe "Forme Rails integration" do
@@ -192,4 +196,8 @@ def o.puts(*) end
192 196
   specify "#form should work without a block" do
193 197
     sin_get('/noblock').should == '<form action="/baz"><fieldset class="inputs"><legend>123</legend><input id="first" name="first" type="text" value="foo"/></fieldset><input type="submit" value="xyz"/></form>'
194 198
   end
  199
+
  200
+  specify "#form should handle Rails SafeBuffers" do
  201
+    sin_get('/safe_buffer').should == '<form action="/baz"><fieldset class="inputs"><legend><b>foo</b></legend><input id="first" name="first" type="text" value="foo"/></fieldset><input type="submit" value="xyz"/></form>'
  202
+  end
195 203
 end

0 notes on commit f711d2b

Please sign in to comment.
Something went wrong with that request. Please try again.