Git Product home page Git Product logo

flutie's Introduction

Flutie

Build Status

Flutie provides some utility view helpers for use with Rails applications.

There are helpers for setting a page title and for generating body classes.

Installation & Upgrading

Flutie is a Railtie. We support the versions of Ruby and Rails listed in .travis.yml.

It should be run as a gem and included in your Gemfile:

gem "flutie"

Helpers

Flutie provides helper methods for use within Rails layouts and views.

Page Title

The page_title method can be used like:

<title><%= page_title %></title>

By default, it will produce results like:

<title>Appname : page title</title>
  • "App name" comes from the module name of the rails application created by your app, i.e. Appname::Application will produce "Appname"
  • "page" comes from trying content_for(:page_title) and assumes you are using content_for with :page_title symbol on your pages.
  • The separator defaults to " : "

These can be overridden by passing an options hash including :app_name, :page_title_symbol and :separator hash keys. For example:

content_for(:site_page_title, 'My title of my page')
page_title(:app_name => 'My app name', :page_title_symbol => :site_page_title, :separator => " | ")

would produce:

<title>My app name | My title of my page</title>

You can also reverse the position of the :app_name and the :site_page_title values by using the :reverse option. For example:

content_for(:site_page_title, 'My title of my page')
page_title(:app_name => 'My app name', :page_title_symbol => :site_page_title, reverse: true)

would produce:

<title>My title of my page : My app name</title>

Body Class

The body_class method can be used like this in a layout:

<body class="<%= body_class %>">

This will produce a string including the controller name and controller-action name pair. For example, The WidgetsController#show action would produce:

<body class="widgets widgets-show">

Anything which has been added via content_for(:extra_body_classes) will be added to the end, for example views like:

content_for(:extra_body_classes, 'special-page')
<body class="<%= body_class %>">

would produce:

<body class="widgets widgets-show special-page">

How to contribute

Please see the CONTRIBUTING file for details.

Credits

thoughtbot

Flutie is maintained and funded by thoughtbot, inc.

Thank you to all the contributors!

The names and logos for thoughtbot are trademarks of thoughtbot, inc.

License

Flutie is Copyright © 2010 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

flutie's People

Contributors

calebhearth avatar croaky avatar dependabot[bot] avatar ehmorris avatar etaque avatar gsterndale avatar jdewyea avatar jferris avatar juanitofatas avatar kriskhaira avatar ktheory avatar mab879 avatar mike-burns avatar mjankowski avatar mrjaba avatar qrush avatar sakuro avatar zacharywelch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.