Hi Paul, your sample seems good, but what I'm trying to do with tabnav is a little bit more complicated.<br><br>You're able to define the block <span style="font-family: courier new,monospace;">do p @foo end </span>
because <span style="font-family: courier new,monospace;">@foo</span> is an instance variable of your class A (that could correspond to the tabnav model) but inside the tabnav I should reference something that exists only in the views's context, not the model.. imagine to evaluate a
<span style="font-family: courier new,monospace;">@foo</span> that's inside another class..<br>
<br>let's see..<br><br><span style="font-family: courier new,monospace;">class MyModel</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> add_tab do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> named {params[:name]}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> end</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">end</span><br style="font-family: courier new,monospace;"><br>the <span style="font-family: courier new,monospace;">params</span> method is raising a syntax error here... Maybe I'm missing something but I couldn't make your sample work if the @foo is in antother class...
<br><br>please highlight me :-)<br><br><div><span class="gmail_quote">On 4/17/07, <b class="gmail_sendername">Paul Battley
</b> <<a href="mailto:pbattley@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">pbattley@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Following on from last night's discussion about the use of 'proc' in
<br>Paolo's TabNav plugin, here's a brief demonstration of how to evaluate<br>the block in the right context without needing 'proc' at all:<br><br>---<br><br>#!/usr/bin/env ruby<br><br>class A<br> def initialize
<br> @foo = 42<br> end<br><br> def define(&blk)<br> @fn = blk<br> end<br><br> def evaluate<br> instance_eval(&@fn)<br> end<br>end<br><br>a = A.new<br>a.define do<br> p @foo<br>end<br>a.evaluate # => 42
<br><br>---<br><br>Paul.<br>_______________________________________________<br>chat mailing list<br><a href="mailto:chat@lrug.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">chat@lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.lrug.org/listinfo.cgi/chat-lrug.org
</a><br></blockquote></div><br><br clear="all"><br>-- <br>Paolo Dona'<br>SeeSaw | Another point of view<br><a href="http://www.seesaw.it" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.seesaw.it
</a><br><a href="mailto:paolo.dona@seesaw.it" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">paolo.dona@seesaw.it
</a><br>personal <a href="http://paolodona.blogspot.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://paolodona.blogspot.com</a>