Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
76 lines (56 sloc) 1.93 KB


Helper for printing headers


  • header.title = Sets current page title
  • header.title_separator = Page title separator, defaults to ' / '
  • header.charset = Sets page charset, defaults to 'utf-8'


Examples say it all

= header.add

= header.js

  • Adds javascript

= header.css

  • Adds stylesheet

= header.add :jquery

  • Adds latest jquery from google cdn

= header.description

  • adds description to page, trims if size is larger then 156 characters beacause that is google limit
  • header.description 'Just mind to put less then 157 characters'
  • if you need more than 156 chars use header.meta

= header.icon(location='/favicon.ico', size=nil)

  • defaults to '/favicon.ico'
  • size defines larger icons, for example google applications

= header.meta(name, content)

  • adds generic meta content

=, content)

  • adds generic meta content
  • facebook uses that

= header.rss(link, title='RSS feed')

  • adds RSS feed

= header.print(page_title) Prints page header, should be in head section

Full HAML example

:ruby code should be of course be in controller

<!DOCTYPE html>
  header.description 'My beautiful site'
  header.title 'Homepage'
         - header.icon
         - header.icon '/images/icon-32.png', 32
         - header.add 'site.css', 'local.js'
         = header.print 'My site'

Future improvements

  • yield block prints script in the footer
  • js and css methods that print javascript in the footer and css in the header
  • facebook helpers for facebook pages and icons

Copyright (c) 2011 [Dino Reic (dux)], released under the MIT license