Class: GetProducts
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- GetProducts
- Defined in:
- app/liquid/tags/spree_tags.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ GetProducts
constructor
A new instance of GetProducts.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ GetProducts
Returns a new instance of GetProducts.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/liquid/tags/spree_tags.rb', line 76 def initialize(tag_name, markup, tokens) unless markup.empty? if markup =~ /per_page:(\d+)/ @per_page = $1.to_i end if markup =~ /type:([-_a-z0-9]+)/ @type = $1 end end @per_page ||= 5 super end |
Instance Method Details
#render(context) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/liquid/tags/spree_tags.rb', line 92 def render(context) @searcher = Spree::Config.searcher_class.new(context.registers[:controller].params) @searcher.current_user = context.registers[:controller].try_spree_current_user @searcher.current_currency = context.registers[:action_view].current_currency @products = @searcher.retrieve_products if @type == 'latest' end if context['capture_variable'] context[context['capture_variable']] ||= @products.per(@per_page) else context['products'] ||= @products.per(@per_page) end '' end |