Yes the example in the docs for block could definitely be improved.<br><br>One might do something like<br><br>&lt;table&gt;<br>&lt;tr mv:block=&quot;products.each do |product&quot;&gt;<br>&lt;td mv:content=&quot;<a href="http://product.name">
product.name</a>&quot;&gt;namehere&lt;/td&gt;<br>&lt;td mv:content=&quot;product.price&quot;&gt;pricehere&lt;/td&gt;<br>&lt;/tr&gt;<br>&lt;/table&gt;<br><br>Alternatively its a better practice these days to use partials for these iterations (however using partials will currently be slower than using direct blocks like above so it is a trade off for maintainability and clean looking code). The following masterview tags will do the same thing by creating and using a _product partial.
<br><br>&lt;table&gt;<br>&lt;tr mv:gen_render=&quot;:partial =&gt; 'store/product', :collection =&gt; @products&quot;&gt;<br>&lt;td mv:content=&quot;<a href="http://product.name">product.name</a>&quot;&gt;namehere&lt;/td&gt;
<br>
&lt;td mv:content=&quot;product.price&quot;&gt;pricehere&lt;/td&gt;<br>
&lt;/tr&gt;<br>&lt;/table&gt;<br><br><br>Yes, you are right we should show the combinations of directives that make sense. Good point!!<br><br>And yes, output from directives is based on the priority of the directive (if specified) so that regardless of how you declare them in the element, they get nested appropriately. Things like mv:if taking precedence over mv:block for instance. The priority if not specified is medium and then some directives override this to be higher or lower so they will nest properly.
<br><br>Thanks for the ideas and input!!<br><br>Jeff<br><br><div><span class="gmail_quote">On 7/6/06, <b class="gmail_sendername">Ed Howland</b> &lt;<a href="mailto:ed.howland@gmail.com">ed.howland@gmail.com</a>&gt; wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If you knew me, you would know I am all about examples. There is no<br>clearer way, IMO, of expressing the intent of a library method than
<br>with an example(s). But examples are sometimes hard to do, at least to<br>do right. Check the win32 API docs for examples of not done right<br>examples.<br><br>That said, it took a little bit to wrap my head around mv:block, at
<br>least from the example. I got the intent of the directive, but the<br>example left me wanting. That said, I'd like to propose this version,<br>modified from the original: (Sorry if it wraps wrong in the email)<br><br>
&lt;div id=&quot;result_list&quot;&gt;<br>&nbsp;&nbsp; &lt;div mv:block=&quot;products.each do |product|&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mv:content=&quot;product.desc&quot;&gt;foobar1&lt;/div&gt;<br>&nbsp;&nbsp; &lt;div mv:replace=&quot;&quot;&gt;foobar2&lt;/div&gt;
<br>&nbsp;&nbsp; &lt;div mv:replace=&quot;&quot;&gt;foobar3&lt;/div&gt;<br>&lt;/div&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;becomes<br><br>&lt;div id=&quot;result_list&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;% products.each do |product| %&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div&gt;&lt;%= 
product.desc %&gt;&lt;/div&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;% end %&gt;<br>&lt;/div&gt;<br><br>What struck me was that you'd want to use the bound variable 'product'<br>inside the loop, and therfore inside the content of the tag. What<br>
isn't clear to end users is that MV directives are stacked, and<br>therefore get rendered as they are popped off the stack*. So combining<br>directives on the same tag creates the resulting XML structure<br>correctly. Hopefully, this example makes that clearer.
<br><br>Generally, I don't like to combine more than one library method in an<br>example, and here I have 3. But MV is a different sort of a beast.<br>Directives are not always meant to used in isolation, so the examples<br>
should reflect that. The final two mv:replace's could be left out, but<br>I felt that in visuallizing the template HTML, the user would probably<br>have 3 example lines in his block for verticle spacing reasons.<br><br><br>
<br>Ed<br><br>*One hopes they are stacked the correct way, regardless of the order<br>in the directive, IOW some priority ordering is in place?<br><br>--<br>Ed Howland<br><a href="http://greenprogrammer.blogspot.com">http://greenprogrammer.blogspot.com
</a><br>_______________________________________________<br>Masterview-users mailing list<br><a href="mailto:Masterview-users@rubyforge.org">Masterview-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/masterview-users">
http://rubyforge.org/mailman/listinfo/masterview-users</a><br></blockquote></div><br>