Sha256: 93d5dab966597465216802a7a68ffc110c4cc13cbcc4f57b34d6730206dae01d
Contents?: true
Size: 607 Bytes
Versions: 8
Compression:
Stored size: 607 Bytes
Contents
require 'cgi' module Slippery module Processors class AddGoogleFont def initialize(font_name, variants = []) @font_name = font_name.freeze @variants = variants.freeze end def call(doc) doc.rewrite('head', &add_font_link) end def add_font_link ->(head) { head << H[:link, {rel: 'stylesheet', type: 'text/css', href: href}] } end def href 'http://fonts.googleapis.com/css?family=' + CGI.escape(@font_name) + (@variants.empty? ? '' : ':' + @variants.join(',')) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems