Created
May 14, 2020 18:32
-
-
Save blairanderson/48feba92981b2ffd81c2b1556e0edd01 to your computer and use it in GitHub Desktop.
write JSON file data to multiple files [ruby]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
require 'active_support/core_ext' | |
require 'json' | |
JSON.parse(File.open("./_data/companies.json").read).each do |company| | |
File.open("./_companies/#{company['name'].parameterize}.md", "w") do |f| | |
f.write "---\n" | |
f.write "layout: company\n" | |
f.write "title: #{company['name']}\n" | |
f.write "categories: prep\n" | |
f.write "website: '#{company['website']}'\n" | |
f.write "location: #{company['location']}\n" | |
f.write "---\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment