Module | QuietLeightbox::QuietLeightboxHelper |
In: |
vendor/plugins/quiet_leightbox/lib/quiet_leightbox.rb
|
The helper module - methods for use within views.
Include Leightbox only if used for the current view, according to the Controller. Invoke using "<%= include_quiet_leightbox_if_used -%>" from within the HEAD section of an XHTML view. If you want your HTML output to be nice and tidy in terms of indentation :-) then pass a string in the optional parameter - it will be inserted before each "<script>" tag in the returned HTML fragment.
Note that a trailing newline is output so you can call the helper with the "-%>" closing ERB tag (as shown in the previous paragraph) to avoid inserting a single blank line into your output in the event that the plugin is not used by the current view.
# File vendor/plugins/quiet_leightbox/lib/quiet_leightbox.rb, line 42 42: def include_leightbox_if_used( line_prefix = '' ) 43: return unless using_quiet_leightbox? 44: 45: data = javascript_include_tag( :defaults ) 46: data << "\n" << javascript_include_tag( 'leightbox/leightbox' ) 47: data << "\n" << stylesheet_link_tag( 'leightbox/leightbox' ) 48: 49: data.gsub( /^/, line_prefix ) + "\n" 50: end