Sha256: a6652ed046db3f15d79a44db02cf23d3f0994c8e1cffafdcd2fc2536995ea2ca

Contents?: true

Size: 661 Bytes

Versions: 2

Compression:

Stored size: 661 Bytes

Contents

require 'deas-erbtags/tag'
require 'deas-erbtags/capture'

module Deas::ErbTags
  module LinkTo

    def self.included(receiver)
      receiver.class_eval{ include Tag, Capture, Method }
    end

    module Method

      def link_to(*args, &block)
        opts, href, content = [
          args.last.kind_of?(::Hash) ? args.pop : {},
          args.pop,
          args.last
        ]
        opts.update(:href => href.to_s) if !href.nil?
        tag = opts.delete(:tag) || opts.delete('tag') || :a

        if block_given?
          capture_tag(tag, opts, &block)
        else
          tag(tag, content || href, opts)
        end
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deas-erbtags-0.5.0 lib/deas-erbtags/link_to.rb
deas-erbtags-0.4.2 lib/deas-erbtags/link_to.rb