Module: Barista::Helpers
- Defined in:
- lib/barista/helpers.rb
Instance Method Summary collapse
- #coffeescript_include_tag(*names) ⇒ Object
- #coffeescript_interpreter_js ⇒ Object
- #coffeescript_tag(code, html_options = {}) ⇒ Object
Instance Method Details
#coffeescript_include_tag(*names) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/barista/helpers.rb', line 13 def coffeescript_include_tag(*names) check_for_helper_method! :javascript_include_tag if Barista. output = defined?(ActiveSupport::SafeBuffer) ? ActiveSupport::SafeBuffer.new : "" output << coffeescript_interpreter_js check_for_helper_method! :content_tag Array(names).each do |name| output << "\n" output << content_tag(:script, '', :type => 'text/coffeescript', :src => normalise_coffeescript_path(name.to_s)) end output else javascript_include_tag(*names) end end |
#coffeescript_interpreter_js ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/barista/helpers.rb', line 4 def coffeescript_interpreter_js return if defined?(@coffeescript_embedded) && @coffeescript_embedded check_for_helper_method! :javascript_include_tag @coffeescript_embedded = true if Barista. javascript_include_tag 'coffeescript' end end |
#coffeescript_tag(code, html_options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/barista/helpers.rb', line 29 def coffeescript_tag(code, = {}) check_for_helper_method! :javascript_tag if Barista. check_for_helper_method! :content_tag output = defined?(ActiveSupport::SafeBuffer) ? ActiveSupport::SafeBuffer.new : "" output << coffeescript_interpreter_js = "\n#<![CDATA[\n#{code}\n#]]>\n" = .html_safe if .respond_to?(:html_safe) output << content_tag(:script, , .merge(:type => 'text/coffeescript')) output else javascript_tag Barista::Compiler.compile(code), end end |