Module: ScriptHelpers::ScriptAndCssHelper
- Defined in:
- app/helpers/script_helpers/script_and_css_helper.rb
Instance Method Summary collapse
- #css(options = {}, &block) ⇒ Object
- #css_contents ⇒ Object
- #css_tag_contents ⇒ Object
- #script(options = {}, &block) ⇒ Object
- #script_contents ⇒ Object
- #script_tag_contents ⇒ Object
Instance Method Details
#css(options = {}, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/script_helpers/script_and_css_helper.rb', line 35 def css( = {}, &block) if .include? :src @_script_helpers_css ||= {} unless @_script_helpers_css[[:src]] @_script_helpers_css[[:src]] = true content_for :css_tags, "\n" content_for :css_tags, stylesheet_link_tag([:src]) end end if block content_for :css, "\n" content_for :css, capture(&block) end end |
#css_contents ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/helpers/script_helpers/script_and_css_helper.rb', line 56 def css_contents contents = content_for :css if contents.present? content_tag :style, contents, :type => "text/css" end end |
#css_tag_contents ⇒ Object
52 53 54 |
# File 'app/helpers/script_helpers/script_and_css_helper.rb', line 52 def css_tag_contents content_for :css_tags end |
#script(options = {}, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/script_helpers/script_and_css_helper.rb', line 3 def script( = {}, &block) if .include? :src @_script_helpers_script ||= {} unless @_script_helpers_script[[:src]] @_script_helpers_script[[:src]] = true content_for :script_tags, "\n" content_for :script_tags, javascript_include_tag([:src]) end end if block return javascript_tag &block if [:inline] content_for :script, "\n" content_for :script, capture(&block) end nil end |
#script_contents ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/helpers/script_helpers/script_and_css_helper.rb', line 27 def script_contents contents = content_for :script if contents.present? javascript_tag contents end end |
#script_tag_contents ⇒ Object
23 24 25 |
# File 'app/helpers/script_helpers/script_and_css_helper.rb', line 23 def script_tag_contents content_for :script_tags end |