Sha256: 05286795b0a12d1f2766aca74d7fdb83817ace81d5a8cae29b8bbda78a0e20bc

Contents?: true

Size: 643 Bytes

Versions: 3

Compression:

Stored size: 643 Bytes

Contents

# encoding: UTF-8

module Spontaneous::Field
  class Tags < Base
    # Just use the standard String editor for now.
    # TODO: This should be replaced with a tags specific one asap.
    has_editor "Spontaneous.Field.String"

    include Enumerable

    def outputs
      [:html, :tags]
    end

    def generate_html(value)
      value
    end

    TAG_PARSER_RE = /"([^"]+)"|([^ ]+)/

    def generate_tags(value)
      return [] if value.blank?
      (value).scan(TAG_PARSER_RE).flatten.compact
    end

    def taglist
      values[:tags] || []
    end

    def each(&block)
      taglist.each(&block)
    end

    self.register
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta4 lib/spontaneous/field/tags.rb
spontaneous-0.2.0.beta3 lib/spontaneous/field/tags.rb
spontaneous-0.2.0.beta2 lib/spontaneous/field/tags.rb