CSV Helper Extension for Middleman
The MIT License (MIT)
Copyright (c) 2014 Lachlan McDonald <lachlan@radelaide.net>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
This file has been truncated. show original
config.rb
# Load Extension (this line is placed in your config.rb file)
require 'csv-helpers.rb'
activate :csv_helpers
csv-helpers.rb
class CSV_Helpers < Middleman::Extension
def initialize(app, options_hash={}, &block)
super
end
helpers do
def csv_data(file)
csv_data = File.read(File.join(data_dir, file))
hash = CSV.new(csv_data, :headers => true, :header_converters => :symbol)
return hash.to_a.map { |row| row.to_hash }
end
This file has been truncated. show original
There are more than three files. show original