Class: PatternsExtension

Inherits:
Middleman::Extension
  • Object
show all
Defined in:
lib/middleman-patterns.rb

Overview

Middleman extension class. Allows overriding default patterns’ directory. Exposes helper methods in helpers.rb to templates in the middleman app. Ignores the patterns directory when building the site by default.

Options:

:patterns_directory
  the local directory patterns are stored in, defaults to "patterns"

:build_patterns
  whether or not to ignore the patterns directory when building the site

Instance Method Summary collapse

Constructor Details

#initialize(app, options_hash = {}, &block) ⇒ PatternsExtension

Returns a new instance of PatternsExtension.



25
26
27
28
29
# File 'lib/middleman-patterns.rb', line 25

def initialize(app, options_hash = {}, &block)
  super

  app.set :patterns_directory, options.patterns_directory
end

Instance Method Details

#after_configurationObject

Handles ignoring the patterns directory during build if this appropriate option is set.



32
33
34
# File 'lib/middleman-patterns.rb', line 32

def after_configuration
  @app.ignore(/#{app.config.setting(:patterns_directory).value}\//) unless options.build_patterns
end