Rick DeNatale wrote:
> On 3/11/08, ara howard <ara.t.howard / gmail.com> wrote:
>>  thought some here might appreciate this
>>
>>    http://drawohara.com/post/28514698
>>
>>  kind regards
>>
>>  a @ http://codeforpeople.com/
> 
> No need for Object#context
> 
>   class View
>     def initialize template
>       @template = template
>     end
> 
>     def render locals = {}
>       context = binding
>       locals.each do |k, v|
>         var = k
>         value = "ObjectSpace._id2ref #{ v.object_id }"
>         definition = "#{ var } = #{ value }"
>         eval definition, context
>       end
>       double_quoted_heredoc = ['<<__template__', @template,
> '__template__'].join("\n")
>       eval double_quoted_heredoc, context
>     end
>   end
> 
>   view = View.new '<body> #{ x + y } </body>'
> 
>   puts view.render(:x => 40, :y => 2)  #=> <body> 42 </body>
> 
> Works just as well.

Not quite.

   view = View.new '<body> #{ x + y } #{locals} </body>'
   puts view.render(:x => 40, :y => 2)  # ==> <body> 42 x40y2 </body>

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407