Sha256: 485dc442b3ca72f7e6c9c08c43924e2fcc0b7c4f3e0ee17f3a56d5ccea4e8561

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

# encoding: utf-8
module Middleman
  module Presentation
    # Plugin Api
    module PluginApi
      # Require some other plugin
      #
      # @param [String, Array] names
      #   The name of the plugin which should be loaded. It also supports
      #   multiple arguments or an array of plugin names.
      #
      # @example String
      #
      #   require_plugin 'name1'
      #
      # @example Multiple Arguments
      #
      #   require_plugin 'name1', 'name2'
      #
      # @example Arrays
      #
      #   require_plugin ['name1', 'name2']
      #
      def require_plugin(*names)
        application.plugins_manager.activate_plugin(names)
      end

      # Add frontend component
      #
      # @param [Hash] component
      #   The component which should be added
      def add_component(component)
        Middleman::Presentation.components_manager.add FrontendComponent.new(**component)
      end

      # Add helpers
      #
      # @example Add helpers via modules
      #
      # add_helpers MyModule1, MyModule2
      #
      # @example Add helpers via code block
      #
      # add_helpers do
      #   def my_helper1
      #     'my_helper1'
      #   end
      # end
      def add_helpers(*m, &block)
        Middleman::Presentation.helpers_manager.add(*m, &block)
      end

      # Add assets which should be imported
      #
      # @param [String] path
      #   Directory where assets are stored
      # def add_assets(path, output_paths: {}, importable_files: [], loadable_files: [], ignorable_files: [])
      def add_assets(component)
        Middleman::Presentation.components_manager.add AssetComponent.new(**component)
      end

      module_function :add_component, :add_helpers, :add_assets
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
middleman-presentation-core-0.17.7 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.17.6 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.17.5 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.17.2 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.17.1 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.17.0 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.16.3 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.16.2 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.16.0 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.16.0.rc2 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.16.0.rc1 lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.16.0.beta lib/middleman-presentation-core/plugin_api.rb
middleman-presentation-core-0.16.0.alpha lib/middleman-presentation-core/plugin_api.rb