Sha256: 77aa8bf6dfa5824cc2f3025b8a16ca023993a87fe5b3d9000faeebb8e1032d67

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module Locomotive
  class MyPlugin
    include Locomotive::Plugin

    module Filters
      def filter(input)
        input
      end
    end

    class MyDrop < ::Liquid::Drop
    end

    class MyTag < ::Liquid::Tag
    end

    before_page_render :my_method1
    after_page_render :my_method2
    around_page_render :my_method3

    before_rack_app_request :my_method1
    after_rack_app_request :my_method2
    around_rack_app_request :my_method3

    class << self
      attr_accessor :custom_attribute
    end

    def self.plugin_loaded
      self.custom_attribute = 'Value'
    end

    def to_liquid
      MyDrop.new
    end

    def config_template_file
      File.join(File.dirname(__FILE__), '..', '..', 'fixtures',
        'config_template.html')
    end

    def self.liquid_filters
      Filters
    end

    def self.liquid_tags
      { 'my_tag' => MyTag }
    end

    def self.javascript_context
      {
        variable: self.custom_attribute,
        method: lambda{|this,word,times| word * times  }
      }
    end

    def my_method1
      'This is my before filter!'
    end

    def my_method2
      'This is my after filter!'
    end

    def my_method3
      'This is my around filter!'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
locomotive_plugins-1.2.0 spec/support/plugins/my_plugin.rb
locomotive_plugins-1.1.1 spec/support/plugins/my_plugin.rb
locomotive_plugins-1.1.0 spec/support/plugins/my_plugin.rb