From 8698a276f937cb1cd6f67f7f213e2ea438500d7e Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 30 May 2011 00:30:16 -0400 Subject: Cleaned out public from repository, updated gitignore, added syntax highlighting tests, improved syntax highlighting and styling of pre blocks. Overriding dynamic gist styling. Added a plugin for pygments caching which should speed things up terrifically. added ender.js as a lightweight way of scripting the DOM, events, etc. Some general typography and semantic html improvements. --- _plugins/iterator.rb | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 _plugins/iterator.rb (limited to '_plugins/iterator.rb') diff --git a/_plugins/iterator.rb b/_plugins/iterator.rb new file mode 100644 index 00000000..da0b5f0a --- /dev/null +++ b/_plugins/iterator.rb @@ -0,0 +1,49 @@ +## +## Author: Jose Gonzalez - https://github.com/josegonzalez +## Source URL: https://github.com/josegonzalez/josediazgonzalez.com/blob/master/_plugins/iterator.rb +## + +#module Jekyll + #class Site + #alias_method :orig_site_payload, :site_payload + + ## Constuct an array of hashes that will allow the user, using Liquid, to + ## iterate through the keys of _kv_hash_ and be able to iterate through the + ## elements under each key. + ## + ## Example: + ## categories = { 'Ruby' => [, ] } + ## make_iterable(categories, :index => 'name', :items => 'posts') + ## Will allow the user to iterate through all categories and then iterate + ## though each post in the current category like so: + ## {% for category in site.categories %} + ## h1. {{ category.name }} + ##
    + ## {% for post in category.posts %} + ##
  • {{ post.title }}
  • + ## {% endfor %} + ##
+ ## {% endfor %} + ## + ## Returns [ { => , => kv_hash[]}, ... ] + + #def make_iterable(kv_hash, options) + #options = {:index => 'name', :items => 'items'}.merge(options) + #result = [] + #kv_hash.sort.each do |key, value| + #result << { options[:index] => key, options[:items] => value } + #end + #result + #end + + #def site_payload + #payload = orig_site_payload + #payload['site']['iterable'].merge!({ + #'categories' => make_iterable(self.categories, :index => 'name', :items => 'posts'), + #'tags' => make_iterable(self.tags, :index => 'name', :items => 'posts') + #}) + #payload + #end + + #end +#end -- cgit v1.2.1