stasis-extensions Build Status

stasis-extensions is a gem that extends the functionality of stasis to support i18n and fingerprinting of assets.

Installation

Add this line to your application's Gemfile:

gem 'stasis-extensions'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stasis-extensions

Usage

i18n helpers

body_class

Use to generate classes for your body (or other html tag). The current locale and the current view name will be included.

translate(key, options = {})

Use in your views to localize text. Aliased as t. See ActionView::Helpers::TranslationHelper.

root_url

Use in your views to generate a "root" url for your site by adding the protocol hostname (looked up as "hostname" in your locale .yml file).

asset support

All files in the css, images and js folders will be fingerprinted with MD5 digests of the source content (allowing simpler use with caching or CDNs).

asset helpers

In addition to compiling the fingerprinted asset files, helper methods have been added for use in views and in sass/scss.

asset_path(file)

Similar to the Rails asset_path helper, the specified path will be expanded to the fingerprinted version.

asset_url(file)

Similar to the preceding asset_path helper, the specified path will be expanded to the fingerprinted version and will be prepended with the protocol and hostname (as provided by the root_url helper above).

asset-url(file)

Similar to the asset_path helper, but the path is rendered for css use (ie. wrapped in url(...)).

content helper

A helper method has been added to support Rails-like deferred content.

content_for(symbol)

Similar to the Rails content_for helper which allows the user to yield content defined in a view from within a layout.

Instead of using yield to render the content within the layout, simply call the helper without a block to retrieve the previously rendered content.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request