Skip to content

Instantly share code, notes, and snippets.

@bbttxu
Created October 7, 2012 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbttxu/3849351 to your computer and use it in GitHub Desktop.
Save bbttxu/3849351 to your computer and use it in GitHub Desktop.
#PROBLEM: how to render HAML in helper like in a view? likely Ruby or Rails issue
module ApplicationHelper
def li_link_to(text, url, options = nil)
link_to_unless_current text, url, options do |text, url, options|
Haml::Engine.new("%li.active= link_to(#{text}, #{url}, #{options})").render
end
end
end
%html
/ paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
/[if lt IE 7 ] <html class="ie6" lang="en">
/[if IE 7 ] <html class="ie7" lang="en">
/[if IE 8 ] <html class="ie8" lang="en">
/[if (gte IE 9)|!(IE)] <html lang="en">
%head
%meta{ :charset => "utf-8" }
/ Uncomment to make IE8 render like IE7
/ <meta http-equiv="X-UA-Compatible" content="IE=7"/>
/ Set the viewport width to device width for mobile
%meta( name="viewport" content="width=device-width, initial-scale=1.0")
%title= content_for?(:title) ? yield(:title) : "Untitled"
/ Included CSS Files
= stylesheet_link_tag "application"
/ Included JS Files
= javascript_include_tag "application"
= csrf_meta_tags
%body
%h1 QCBS
%ul#navigation
= li_link_to 'Current', '/shops/current'
%li
%a{ :href=>"/shops" } Shops
%li
%a{ :href=>"/volunteers" } Volunteers
%li
%a{ :href=>"/sessions"} Sessions
= yield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment