Sha256: e28ed99a4ea793ad036ceb989051ae60eb0b58fb84f1d88c259b799bdf7f8922

Contents?: true

Size: 365 Bytes

Versions: 12

Compression:

Stored size: 365 Bytes

Contents

description 'Tag which creates sorted list'

Tag.define :sort, optional: %w(ordered descending) do |context, attrs, content|
  type = attrs['ordered'] == 'ordered' ? 'ol' : 'ul'
  order = attrs['descending'] == 'descending' ? -1 : 1
  %{<#{type}>#{content.strip.split(/\n/).sort {|a,b| (a <=> b) * order }.map {|x| "<li>#{escape_html x}</li>"}.join}</#{type}>}
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
olelo-0.9.15 plugins/tags/sort.rb
olelo-0.9.14 plugins/tags/sort.rb
olelo-0.9.13 plugins/tags/sort.rb
olelo-0.9.12 plugins/tags/sort.rb
olelo-0.9.11 plugins/tags/sort.rb
olelo-0.9.10 plugins/tags/sort.rb
olelo-0.9.9 plugins/tags/sort.rb
olelo-0.9.8 plugins/tags/sort.rb
olelo-0.9.7 plugins/tags/sort.rb
olelo-0.9.6 plugins/tags/sort.rb
olelo-0.9.5 plugins/tags/sort.rb
olelo-0.9.4 plugins/tags/sort.rb