Sha256: f565c386cc0d342ce77df39c58c6a92ad99cad33afb36e6988c782bacb53233a

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module Metamagic
  module ViewHelper
    def meta(hash = {})
      metamagic_renderer.add hash
    end

    def metamagic(hash = {})
      if title_template = hash.delete(:title_template)
        # Deprecation warning
        Rails.logger.warn "[Metamagic] Using `metamagic title_template: #{title_template.inspect}` has been deprecated. Please use `metamagic title: #{title_template.inspect}` instead."
        hash[:title] = title_template
      end

      # Loop through special options
      hash.slice(:site, :separator).each do |key, value|
        metamagic_renderer.send("#{key}=", value)
        hash.delete key
      end

      metamagic_renderer.add hash, true
      metamagic_renderer.render
    end

    def method_missing(method, *args, &block)
      if metamagic_renderer.has_tag_type?(method)
        args.first.tap do |value|
          meta method => value
        end
      else
        super
      end
    end

    private

    def metamagic_renderer
      @metamagic_renderer ||= Renderer.new(self)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
metamagic-3.1.7 lib/metamagic/view_helper.rb
metamagic-3.1.6 lib/metamagic/view_helper.rb
metamagic-3.1.4 lib/metamagic/view_helper.rb
metamagic-3.1.3 lib/metamagic/view_helper.rb