Class: HtmlSlicer::Helpers::Tag
- Inherits:
-
Object
- Object
- HtmlSlicer::Helpers::Tag
- Defined in:
- lib/html_slicer/helpers/tags.rb
Overview
This part of code is almost completely ported from Kaminari
gem by Akira Matsuda. Look at github.com/amatsuda/kaminari/tree/master/lib/kaminari/helpers
A tag stands for an HTML tag inside the paginator. Basically, a tag has its own partial template file, so every tag can be rendered into String using its partial template.
The template file should be placed in your app/views/html_slicer/ directory with underscored class name (besides the “Tag” class. Tag is an abstract class, so _tag parital is not needed).
e.g.) PrevLink -> app/views/html_slicer/_prev_link.html.erb
When no matching template were found in your app, the engine’s pre installed template will be used.
e.g.) Paginator -> $GEM_HOME/html_slicer-x.x.x/app/views/html_slicer/_paginator.html.erb
Instance Method Summary collapse
-
#initialize(template, options = {}) ⇒ Tag
constructor
:nodoc:.
- #slice_url_for(slice) ⇒ Object
-
#to_s(locals = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize(template, options = {}) ⇒ Tag
:nodoc:
22 23 24 25 26 27 |
# File 'lib/html_slicer/helpers/tags.rb', line 22 def initialize(template, = {}) #:nodoc: @template, @options = template, .dup @param_name = @options.delete(:param_name) @theme = @options[:theme] ? "#{@options.delete(:theme)}/" : '' @params = @options[:params] ? template.params.merge(@options.delete :params) : template.params end |
Instance Method Details
#slice_url_for(slice) ⇒ Object
33 34 35 36 |
# File 'lib/html_slicer/helpers/tags.rb', line 33 def slice_url_for(slice) # [email protected]_hashup+: returns deep merged params with a new slice number value. @template.url_for @params.merge_hashup(*@param_name, (slice <= 1 ? nil : slice)) end |
#to_s(locals = {}) ⇒ Object
:nodoc:
29 30 31 |
# File 'lib/html_slicer/helpers/tags.rb', line 29 def to_s(locals = {}) #:nodoc: @template.render :partial => "html_slicer/#{@theme}#{self.class.name.demodulize.underscore}", :locals => @options.merge(locals) end |