Sha256: 61bd91a96747e8764fc6c911d894b45775d93e3412d2e13874d3ed9bdb94c89b

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 Bytes

Contents

# Syntax
# {% asset_data tag'test', as:'sale_vehicles' %}

class AssetDataTag < Cms::DataTag
  def get_data
    raise Liquid::ArgumentError.new("The required 'tag' parameter is missing.") if options[:tag].blank?

    collection = uses_random do |random_func|
      assets = context_object.assets.tagged_with(options[:tag])

      assets = if options[:random] == true
        assets.order(random_func)
      else
        assets.order('cms_assets.created_at ASC')
      end

      assets = assets.limit(options[:limit]) if options[:limit]

      assets.all
    end

    yield 'assets', collection
  end
end

Liquid::Template.register_tag('asset_data', AssetDataTag)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
liquid_cms-0.3.2.0 app/liquid/tags/asset_search_tag.rb
liquid_cms-0.3.1.0 app/liquid/tags/asset_search_tag.rb