class Middleman::GeoPattern::Extension
Extension
namespace
Public Class Methods
new(app, options_hash = {}, &block)
click to toggle source
Calls superclass method
# File lib/middleman-geo_pattern/extension.rb, line 12 def initialize(app, options_hash = {}, &block) # Call super to build options from the options_hash super require 'geo_pattern' # set up your extension # puts options.my_option end
Public Instance Methods
after_configuration()
click to toggle source
# File lib/middleman-geo_pattern/extension.rb, line 22 def after_configuration # Do something end
geo_pattern( input, patterns: extensions[:geo_pattern].options.patterns, color: extensions[:geo_pattern].options.color, base_color: extensions[:geo_pattern].options.base_color, is_content_tag: extensions[:geo_pattern].options.is_content_tag, html_tag: extensions[:geo_pattern].options.html_tag, css_class: extensions[:geo_pattern].options.css_class, **options, &block )
click to toggle source
Generate the geo pattern
@param [#to_s] input
The input used to generate the pattern
@param [Array, Symbol) patterns
The patterns which are allowed to generate
@param [String] color
The color to use for the background of the pattern. You can either use "color" or "base_color".
@param [String] base_color
The base_color to use for the background of the pattern. You can either "use color" or "base_color".
@param [Hash] options
All other options are passed on to the tag helper
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/ParameterLists
# File lib/middleman-geo_pattern/extension.rb, line 52 def geo_pattern( input, patterns: extensions[:geo_pattern].options.patterns, color: extensions[:geo_pattern].options.color, base_color: extensions[:geo_pattern].options.base_color, is_content_tag: extensions[:geo_pattern].options.is_content_tag, html_tag: extensions[:geo_pattern].options.html_tag, css_class: extensions[:geo_pattern].options.css_class, **options, &block ) pattern = ::GeoPattern.generate( input, patterns: patterns, color: color, base_color: base_color ) style = format('background-image: %s', pattern.to_data_uri) style += options.delete(:style) if options[:style] # rubocop:disable Metrics/LineLength return public_send(:content_tag, html_tag, nil, **options, class: css_class, style: style, &block) if is_content_tag == true # rubocop:enable Metrics/LineLength public_send(:tag, html_tag, **options, class: css_class, style: style) end