Skip to content

Instantly share code, notes, and snippets.

@compleatang
Created August 6, 2014 15:19
Show Gist options
  • Save compleatang/b5b0a8d77c6364689ad6 to your computer and use it in GitHub Desktop.
Save compleatang/b5b0a8d77c6364689ad6 to your computer and use it in GitHub Desktop.
render lmd contract
def build_contract params
contract_file = File.join( File.dirname(__FILE__), 'public', 'consulting_agreement.lmd' )
values = { "client_name" => "#{params[:name]}", "date" => "#{Time.new.strftime('%B %d, %Y')}", "standard" => "false", "express" => "false", "additional" => "false", "hourly" => "false" }
case params[:package]
when 'standard'
values["standard"] = "true"
when 'express'
values["express"] = "true"
when 'additional'
values["additional"] = "true"
when 'hourly'
values["hourly"] = "true"
end
contract = values.to_yaml + File.read( contract_file )
temp = Tempfile.new 'lmd'
File.open(temp.path, 'w'){ |f| f.write contract }
contract = Maruku.new( `bundle exec legal2md -m #{temp.path} -` ).to_html
return contract
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment