Blame docs/website/_plugins/sorted_for.rb
|
Packit Service |
48484a |
module Jekyll
|
|
Packit Service |
48484a |
class SortedForTag < Liquid::For
|
|
Packit Service |
48484a |
def render(context)
|
|
Packit Service |
48484a |
sorted_collection = context[@collection_name].dup
|
|
Packit Service |
48484a |
sorted_collection = sorted_collection.sort_by { |i| i.to_liquid[@attributes['sort_by']] }
|
|
Packit Service |
48484a |
|
|
Packit Service |
48484a |
sorted_collection_name = "#{@collection_name}_sorted".sub('.', '_')
|
|
Packit Service |
48484a |
context[sorted_collection_name] = sorted_collection
|
|
Packit Service |
48484a |
@collection_name = sorted_collection_name
|
|
Packit Service |
48484a |
|
|
Packit Service |
48484a |
super
|
|
Packit Service |
48484a |
end
|
|
Packit Service |
48484a |
|
|
Packit Service |
48484a |
def end_tag
|
|
Packit Service |
48484a |
'endsorted_for'
|
|
Packit Service |
48484a |
end
|
|
Packit Service |
48484a |
end
|
|
Packit Service |
48484a |
end
|
|
Packit Service |
48484a |
|
|
Packit Service |
48484a |
Liquid::Template.register_tag('sorted_for', Jekyll::SortedForTag)
|