Method: Hammock::JavascriptBuffer::InstanceMethods#append_javascript
- Defined in:
- lib/hammock/javascript_buffer.rb
#append_javascript(snippet) ⇒ Object
Add snippet to the request’s domready javascript cache.
The contents of this cache can be rendered into a jQuery $(function() { ... }) block within a <script type="text/javascript"> block by calling javascript_for_page within the <head> of the layout.
| 18 19 20 21 22 | # File 'lib/hammock/javascript_buffer.rb', line 18 def append_javascript snippet # TODO This should be an array of strings. @_domready_javascript ||= '' @_domready_javascript << snippet.strip.end_with(';') << "\n\n" unless snippet.nil? end |