Sha256: 0635605b0546febad22eb3d15101242b1e17b025b3d1c9c6d73d7e44c0bce82a

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'type_station/blocks'

module TypeStation
  module Helpers
    module New

      # ts_edit :page, @page, fields: ['title'], content_tag: :span
      # ts_edit collection: 'my_collection', @page, fields: ['title'], content_tag: :span

      def ts_edit(key, model, user_options = {}, &block)
        content = capture(&block)
        type = key.is_a?(Hash) ? key.to_a.first.first : key
        options = { type: type }.merge(user_options)

        if type_station_current_user
          klass ||= "TypeStation::Blocks::Edit#{options[:type].to_s.classify}".constantize
          klass.new(model, key, options).render(content)
        else
          TypeStation::Blocks::Stickable.new(model, key, options).render(content)
        end      
      end


      def ts_link(model, key, options = {}, &block)
        content = capture(&block)

        if type_station_current_user
          TypeStation::Blocks::EditLink.new(model, key, options).render(content)
        else
          TypeStation::Blocks::StaticLink.new(model, key, options).render(content)
        end 
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
type_station-0.1.3 lib/type_station/helpers/edit.rb
type_station-0.1.1 lib/type_station/helpers/edit.rb