Module: Jammit::Helper
- Defined in:
- lib/jammit/helper.rb
Overview
The Jammit::Helper module, which is made available to every view, provides helpers for writing out HTML tags for asset packages. In development you get the ordered list of source files – in any other environment, a link to the cached packages.
Constant Summary collapse
- DATA_URI_START =
"<!--[if (!IE)|(gte IE 8)]><!-->"
- DATA_URI_END =
"<!--<![endif]-->"
- MHTML_START =
"<!--[if lte IE 7]>"
- MHTML_END =
"<![endif]-->"
Instance Method Summary collapse
-
#include_javascripts(*packages) ⇒ Object
Writes out the URL to the bundled and compressed javascript package, except in development, where it references the individual scripts.
-
#include_stylesheets(*packages) ⇒ Object
If embed_assets is turned on, writes out links to the Data-URI and MHTML versions of the stylesheet package, otherwise the package is regular compressed CSS, and in development the stylesheet URLs are passed verbatim.
-
#include_templates(*packages) ⇒ Object
Writes out the URL to the concatenated and compiled JST file – we always have to pre-process it, even in development.
Instance Method Details
#include_javascripts(*packages) ⇒ Object
Writes out the URL to the bundled and compressed javascript package, except in development, where it references the individual scripts.
27 28 29 30 31 32 |
# File 'lib/jammit/helper.rb', line 27 def include_javascripts(*packages) = packages.map do |pack| should_package? ? Jammit.asset_url(pack, :js) : Jammit.packager.individual_urls(pack.to_sym, :js) end html_safe(javascript_include_tag(.flatten)) end |
#include_stylesheets(*packages) ⇒ Object
If embed_assets is turned on, writes out links to the Data-URI and MHTML versions of the stylesheet package, otherwise the package is regular compressed CSS, and in development the stylesheet URLs are passed verbatim.
17 18 19 20 21 22 23 |
# File 'lib/jammit/helper.rb', line 17 def include_stylesheets(*packages) = packages. return individual_stylesheets(packages, ) unless should_package? disabled = (.delete(:embed_assets) == false) || (.delete(:embed_images) == false) return html_safe(packaged_stylesheets(packages, )) if disabled || !Jammit. return html_safe((packages, )) end |
#include_templates(*packages) ⇒ Object
Writes out the URL to the concatenated and compiled JST file – we always have to pre-process it, even in development.
36 37 38 |
# File 'lib/jammit/helper.rb', line 36 def include_templates(*packages) raise DeprecationError, "Jammit 0.5+ no longer supports separate packages for templates.\nYou can include your JST alongside your JS, and use include_javascripts." end |