Sha256: ec94659ff5e2aed69b17145482351ae34b598fca9cc9e37dd1fdbda65ac7d6d1

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

module Google
  module Webfonts

    # Public: Helper module that includes the google_webfonts_link_tag method.
    # This module is automatically included in your Rails view helpers.
    module Helper
      # Public: Generates a Google Webfonts link tag
      #
      # If you need to specify a font size, use a Hash. Symbols will be
      # titleized, so if the font you're using uses a specialized case
      # (e.g: "PT Sans"), then you'll need to use a String.
      #
      # You can specify subsets by using the :subset option. Note that this must
      # be a Symbol. "Subset" and "subset" would be turned into a font.
      #
      # options - The font options. This can be a String, Symbol, or Hash, or
      #           a combination of all three.
      #
      # Examples
      #
      #   google_webfonts_link_tag "PT Sans"
      #
      #   google_webfonts_link_tag :droid_sans
      #
      #   google_webfonts_link_tag droid_sans: [400, 700]
      #
      #   google_webfonts_link_tag droid_sans: [400, 700],
      #                            yanone_kaffeesatz: 700
      #
      #   google_webfonts_link_tag :droid_sans,
      #                            yanone_kaffeesatz: 400,
      #                            "PT Sans" => [400, 700]
      #
      #   google_webfonts_link_tag :droid_sans, subset: %w[latin cyrillic]
      #
      # Returns a <link> tag for the Google Webfonts stylesheet.
      # Raises ArgumentError if no options are passed.
      def google_webfonts_link_tag(*opts)
        raise ArgumentError, 'expected at least one font', caller if opts.empty?
        LinkTag.new(request, *opts).result
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
GoogleWebfonts-0.3.0 lib/google-webfonts/helper.rb
google-webfonts-0.2.0 lib/google-webfonts/helper.rb