www.myowndb.com - rails http://www.myowndb.com/taxonomy/term/33/0 en Using rails' escape_javascript outside of views http://www.myowndb.com/node/63 <p><a href="http://www.rubyonrails.com">Rails</a> provides a handy function to escape string to be used in your javascript code. Unfortunately, it is only available in your views. It is very easy though to make it available outside of views, eg in your helpers, as it suffices to require and include one module:</p> <pre class="brush:ruby"> require 'action_view/helpers/javascript_helper' include ActionView::Helpers::JavaScriptHelper # escape_javascript is available here. </pre><p><a href="http://www.myowndb.com/node/63" target="_blank">read more</a></p> http://www.myowndb.com/node/63#comments javascript rails Tue, 16 Mar 2010 16:22:45 +0000 rb 63 at http://www.myowndb.com