Last active
August 28, 2015 14:33
-
-
Save op-ct/fcb58c042e1b6c07e6a1 to your computer and use it in GitHub Desktop.
Simple ERB templater
This file contains 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 'erb' | |
require 'ostruct' | |
desc 'Generate a README.md using the module name' | |
task 'generate', [:name] do |t, args| | |
metadata = OpenStruct.new( args.to_hash ) | |
erb_file = File.expand_path('README.md.erb', File.dirname(__FILE__)) | |
template = File.open( erb_file, 'r').readlines.join("\n") | |
content = ERB.new template | |
File.open( 'README.md', 'w' ){ |f| f.puts content.result(binding) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
# generate README.md for module 'awesomesauce' rake -f /path/to/Rakefile generate[awesomesauce]
Notes
README.md.erb
has to be in the same directory asRakefile