Skip to content

Instantly share code, notes, and snippets.

@mcasimir
Created May 24, 2012 00:01
Show Gist options
  • Save mcasimir/2778541 to your computer and use it in GitHub Desktop.
Save mcasimir/2778541 to your computer and use it in GitHub Desktop.
Google fonts helper for Ruby on Rails
Gem::Specification.new do |s|
s.name = 'google_fonts_helper'
s.summary = 'Google fonts helper for Ruby on Rails'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.files = %w(google_fonts_helper.rb)
s.require_path = '.'
s.author = 'Maurizio Casimirri'
s.email = '[email protected]'
end
module Mcasimir
module GoogleFontsHelper
def google_fonts_link_tag(*fonts)
families = fonts.map {|f| f.to_s.gsub("_", " ").titleize.gsub(" ", "+")}.join("|")
html = <<-STR
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=#{families}" type="text/css" />
STR
html.html_safe
end
end
end
ActionView::Base.send :include, Mcasimir::GoogleFontsHelper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment