<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users549</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/549" rel="self"/>
  <title>lifo</title>
  <updated>Sat Apr 12 15:38:04 -0700 2008</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor4873</id>
    <published>2008-04-12T15:38:04-07:00</published>
    <title>[Ruby] On Given a hash of variables, render an ERB template</title>
    <content type="html">&lt;p&gt;Dont make me do these things again :-(&lt;/p&gt;

&lt;pre&gt;require 'erb'
require 'ostruct'

vars = OpenStruct.new :first =&amp;gt; 'Mislav', 'last' =&amp;gt; 'Marohnic'
template = 'Name: &amp;lt;%= first %&amp;gt; &amp;lt;%= last %&amp;gt;'
puts ERB.new(template).result(vars.send(:binding))&lt;/pre&gt;</content>
    <author>
      <name>lifo</name>
      <email>pratiknaik@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/281-given-a-hash-of-variables-render-an-erb-template/refactors/4873" rel="alternate"/>
  </entry>
</feed>

