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