Method: Jekyll::PaginateV2::Generator::Utils.sort_get_post_data
- Defined in:
- lib/jekyll-paginate-v2/generator/utils.rb
.sort_get_post_data(post_data, sort_field) ⇒ Object
Retrieves the given sort field from the given post the sort_field variable can be a hierarchical value on the form “parent_field:child_field” repeated as many times as needed only the leaf child_field will be retrieved
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/jekyll-paginate-v2/generator/utils.rb', line 104 def self.sort_get_post_data(post_data, sort_field) # Begin by splitting up the sort_field by (;,:.) sort_split = sort_field.split(":") sort_value = post_data sort_split.each do |r_key| key = r_key.downcase.strip # Remove any erronious whitespace and convert to lower case if !sort_value.has_key?(key) return nil end # Work my way through the hash sort_value = sort_value[key] end # If the sort value is a hash then return nil else return the value if( sort_value.is_a?(Hash) ) return nil else return sort_value end end |