doc/directives.html in masterview-0.2.5 vs doc/directives.html in masterview-0.3.0

- old
+ new

@@ -1,10 +1,10 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE html +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>MasterView - Directives Reference</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> @@ -23,27 +23,31 @@ <div id="headerNav"> <div> &middot;&nbsp; <a href="./index.html">Doc Home</a> &nbsp;|&nbsp; +<a href="./about.html">About</a> +&nbsp;|&nbsp; <a href="./installation.html">Installation</a> &nbsp;|&nbsp; <a href="./configuration.html">Configuration</a> &nbsp;|&nbsp; <a href="./guide.html">Usage</a> &nbsp;|&nbsp; <a href="./directives.html">Directives</a> -&nbsp;&nbsp; -<a href="./media_list.html">Media (Videos/Illustrations)</a> +&nbsp;|&nbsp; +<a href="./developer.html">Developers</a> +&nbsp;|&nbsp; +<a href="./media_list.html">Screencasts</a> &nbsp;&middot; </div> </div> <div id="pageBody"> <div id="bodyContent"> -<h1>MasterView - Directives Reference</h1> +<h1>MasterView Directives Reference</h1> <p>MasterView template processing directives are encoded in an (x)html template using attribute markup. A MasterView directive is an element attribute in the <span class="directiveName">mv:</span> namespace. By convention, Masterview directive attribute names use lower-case letters with @@ -79,23 +83,23 @@ </pre> <p>A typical use would be to specify the generated output for the main content of a template <code>one/two/foo.html</code> with the directive <code>mv:generate="{template_path}"</code>. -This keyword notation avoids the need to replicate the template's own file name or -it's relative path within the Rails <code>app/views</code> directory in the +This keyword notation avoids the need to replicate the template's own file name or +it's relative path within the Rails <code>app/views</code> directory in the directive markup in the template. </p> <h3>Default generation (output)</h3> <p> Typically MasterView template files will contain mv:generate or mv:gen_partial directives to tell MasterView where to output the rendered rhtml. However if none are found in the template file, MasterView will automatically add in a mv:generate="{template_path}" to the body tag -if found otherwise the root element. Additionally if MasterView was adding this to the body tag, -it will add in a mv:omit_tag="" which will prevent the body tag from being included in the generated -output. If you wish to disable this default generate mechanism, set the +if found otherwise the root element. Additionally if MasterView was adding this to the body tag, +it will add in a mv:omit_tag="" which will prevent the body tag from being included in the generated +output. If you wish to disable this default generate mechanism, set the config.default_parser_options[:default_generate] = false in your masterview settings or environments files. </p> @@ -152,10 +156,14 @@ <tr> <td class="directive"><a href="#mv_block">mv:block</a></td> <td>Expands to the equivalent rhtml (erb) block code around this element</td> </tr> <tr> +<td class="directive"><a href="#mv_eval">mv:eval</a></td> +<td>Inserts an rhtml evaluation expression for the attribute value prior to this element</td> +</tr> +<tr> <td class="directive"><a href="#mv_if">mv:if</a></td> <td>Wraps this element with an <code>if... end</code> block using the attribute contents for the condition</td> </tr> <tr> <td class="directive"><a href="#mv_elsif">mv:elsif</a></td> @@ -196,10 +204,18 @@ Used on <code>&lt;a&gt;</code> link elements )</span> </td> </tr> <tr> +<td class="directive"><a href="#mv_link_to_function">mv:link_to_function</a></td> +<td>Replaces this element using the Rails <code>link_to_function</code> helper which creates a link which calls a JavaScript function. +<span class="explanation">( +Used on <code>&lt;a&gt;</code> link elements +)</span> +</td> +</tr> +<tr> <td class="directive"><a href="#mv_link_to_if">mv:link_to_if</a></td> <td>Replaces this element using the Rails <code>link_to_if</code> helper <span class="explanation">( Used on <code>&lt;a&gt;</code> link elements )</span> @@ -237,13 +253,17 @@ )</span> </td> </tr> <tr> <td class="directive"><a href="#mv_form">mv:form</a></td> -<td>Replaces the start and end tags of this element using the Rails <code>form_tag</code> and <code>form_tag</code> helpers</td> +<td>Replaces the start and end tags of this element using the Rails <code>form_tag</code> helper and closing form tag</td> </tr> <tr> +<td class="directive"><a href="#mv_form_remote">mv:form_remote</a></td> +<td>Replaces the start and end tags of this element using the Rails <code>form_remote_tag</code> helper and a closing form tag for Ajax-enabled form submission using the Prototype library</td> +</tr> +<tr> <td class="directive"><a href="#mv_hidden_field">mv:hidden_field</a></td> <td>Replaces this element with a <code>hidden</code> input element using the Rails <code>hidden_tag</code> helper. <span class="explanation">( Used on <code>&lt;input&gt;</code> form elements )</span> @@ -582,10 +602,31 @@ &lt;% } %&gt; Its all based on the ruby and rails syntax while keeping things xhtml and designer friendly. </pre> +<a name="mv_eval"></a> +<h4>mv:eval</h4> +<p> +mv:eval=&quot;rubyExpression&quot; +</p> +<pre> + At runtime this causes an rhtml evaluation expression for the attribute value + to be inserted into the output preceding this element, for example... + + &lt;table mv:eval=&quot;num_alerts = 0&quot;&gt; + ... some table content here ... + &lt;/table&gt; + + becomes + + &lt;% num_alerts = 0 %&gt; + &lt;table&gt; + ... some table content here ... + &lt;/table&gt; +</pre> + <a name="mv_if"></a> <h4>mv:if</h4> <p> mv:if=&quot;yourIfConditionHere&quot; </p> @@ -709,11 +750,11 @@ <p> mv:image_tag=&quot;cat.jpg&quot; </p> <pre> Replaces the tag with a image_tag helper, size is determined by width and height, other html attributes - are passed through. for example... + are passed through. for example... &lt;img src=&quot;../../../public/images/cat.jpg&quot; mv:image_tag=&quot;cat.jpg&quot;/> becomes @@ -724,12 +765,12 @@ becomes &lt;%= image_tag 'cat.jpg', :alt =&gt; 'my cat', :size =&gt; '20x10' %&gt; - Also if path isn't specified in the mv:image_tag attribute value then it will infer the path looking - for what follows the public/images/ in the src atttribute, like so + Also if path isn't specified in the mv:image_tag attribute value then it will infer the path looking + for what follows the public/images/ in the src atttribute, like so &lt;img src=&quot;../../../public/images/cat.jpg&quot; mv:image_tag=&quot;&quot;/> becomes @@ -752,20 +793,20 @@ becomes &lt;%= javascript_include_tag 'prototype.js' %&gt; - You can also use a symbol + You can also use a symbol &lt;script type=&quot;text/javascript&quot; src=&quot;../../../public/javascripts/prototype.js&quot; mv:javascript_include=&quot;:defaults&quot;&gt;&lt;/script&gt; becomes &lt;%= javascript_include_tag :defaults %&gt; - And you can have the path inferred from the src path (uses the relative path to public/javascripts) + And you can have the path inferred from the src path (uses the relative path to public/javascripts) &lt;script type=&quot;text/javascript&quot; src=&quot;../../../public/javascripts/prototype.js&quot; mv:javascript_include=&quot;&quot;&gt;&lt;/script&gt; becomes @@ -791,10 +832,25 @@ becomes &lt;%= link_to 'New product', :action =&gt; 'new' %&gt; </pre> +<a name="mv_link_to_function"></a> +<h4>mv:link_to_function</h4> +<p> +mv:link_to_function=&quot;mv:link_to_if=&quot;function, options&quot;&quot; +</p> +<pre> + Replaces the tag with a link_to_function helper. The attribute values + contains the function to call, along with optional keyword arguments + to pass to the link_to_function helper. The content of the element + is used as the function name. + + ### todo: add example here ### + +</pre> + <a name="mv_link_to_if"></a> <h4>mv:link_to_if</h4> <p> mv:link_to_if=&quot;linkToIfConditionAndOption&quot; </p> @@ -860,20 +916,20 @@ <h4>mv:check_box</h4> <p> mv:check_box=&quot;product, name&quot; </p> <pre> - Replaces this element with the check_box helper. It quotes the object and name if necessary, and merges any - html attributes into options if supplied + Replaces this element with the check_box helper. It quotes the object and name if necessary, and merges any + html attributes into options if supplied &lt;input type="checkbox" mv:check_box=&quot;product, name&quot;/&gt; becomes &lt;% check_box 'product', 'name' %&gt; - and + and &lt;input type="checkbox" class=&quot;green&quot; id=&quot;cb1&quot; mv:check_box=&quot;product, name, {:readonly =&gt; true}, &apos;yes,&apos;, &apos;no&apos;&quot;/&gt; becomes @@ -886,31 +942,31 @@ <p> mv:collection_select=&quot;product, category, Category.find_all, id, name&quot; </p> <pre> Replaces the tag with a select helper, it quotes the object and method if necessary, and - merges any html attributes into the html_options + merges any html attributes into the html_options - &lt;select mv:collection_select=&quot;product, category, Category.find_all, id, name&quot;&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;/select&gt; - + &lt;select mv:collection_select=&quot;product, category, Category.find_all, id, name&quot;&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;/select&gt; + becomes &lt;%= collection_select &apos;product&apos;, &apos;category&apos;, Category.find_all, &apos;id&apos;, &apos;name&apos; %&gt; and - &lt;select size=&quot;3&quot; mv:collection_select=&quot;product, category, Category.find_all, id, name, {}, :readonly => true &quot;&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;/select&gt; - + &lt;select size=&quot;3&quot; mv:collection_select=&quot;product, category, Category.find_all, id, name, {}, :readonly => true &quot;&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;/select&gt; + becomes &lt;%= collection_select &apos;product&apos;, &apos;category&apos;, Category.find_all, &apos;id&apos;, &apos;name&apos;, {}, :readonly => true, :size => 3 %&gt; @@ -920,30 +976,40 @@ <h4>mv:form</h4> <p> mv:form=&quot;:action =&gt; &#8216;new&#8217;&quot; </p> <pre> - Replaces this tag and closing tag with the form_tag and end_form_tag helpers. It also pulls the + Replaces this tag and closing tag with the form_tag helper and a closing form tag. It also pulls the method and multipart attributes from the element and merges that into the form_tag options, for example... &lt;form mv:form=&quot;:action =&gt; 'new'&quot;&gt;foobar&lt;/form&gt; becomes - &lt;% form_tag :action =&gt; 'new' %&gt; + &lt;%= form_tag( :action =&gt; 'new') %&gt; foobar - &lt;% end_form_tag %&gt; + &lt;/form&gt; &lt;form method=&quot;GET&quot; mv:form=&quot;:action =&gt; 'new'&quot;&gt;foobar&lt;/form&gt; becomes - &lt;% form_tag { :action =&gt; 'new' }, :method =&gt; 'GET' %&gt; + &lt;%= form_tag( { :action =&gt; 'new' }, :method =&gt; 'GET') %&gt; foobar - &lt;% end_form_tag %&gt; + &lt;/form&gt; </pre> +<a name="mv_form_remote"></a> +<h4>mv:form_remote</h4> +<p> +mv:form_remote=&quot;:action =&gt; &#8216; url_for(:controller => "some", :action => "place")&#8217;&quot; +</p> +<pre> + Replaces this tag and closing tag with the form_remote_tag helper and a closing form tag + ### needs work - fix prototype and add example ### +</pre> + <a name="mv_hidden_field"></a> <h4>mv:hidden_field</h4> <p> mv:hidden_field=&quot;object, method&quot; </p> @@ -987,11 +1053,11 @@ <p> mv:radio_button=&quot;product, category, 'clothing'&quot; </p> <pre> Replaces the tag with a radio_button helper, it quotes the object and method if necessary, and - merges any html attributes into the options + merges any html attributes into the options &lt;input type=&quot;radio&quot; mv:radio_button=&quot;product, category, 'clothing'&quot;/&gt; becomes @@ -1013,31 +1079,31 @@ <p> mv:select=&quot;product, category, Category.find_all.collect{|c| [c.name, c.id]}&quot; </p> <pre> Replaces the tag with a select helper, it quotes the object and method if necessary, and - merges any html attributes into the html_options + merges any html attributes into the html_options - &lt;select mv:select=&quot;product, category, Category.find_all.collect{|c| [c.name, c.id]}&quot;&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;/select&gt; - + &lt;select mv:select=&quot;product, category, Category.find_all.collect{|c| [c.name, c.id]}&quot;&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;/select&gt; + becomes &lt;%= select &apos;product&apos;, &apos;category&apos;, Category.find_all.collect{|c| [c.name, c.id]} %&gt; and - &lt;select size=&quot;3&quot; mv:select=&quot;product, category, Category.find_all.collect{|c| [c.name, c.id]}, {}, :readonly => true &quot;&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;option&&gt;One&lt;/option&gt; - &lt;/select&gt; - + &lt;select size=&quot;3&quot; mv:select=&quot;product, category, Category.find_all.collect{|c| [c.name, c.id]}, {}, :readonly => true &quot;&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;option&gt;One&lt;/option&gt; + &lt;/select&gt; + becomes &lt;%= select &apos;product&apos;, &apos;category&apos;, Category.find_all.collect{|c| [c.name, c.id]}, {}, :readonly => true, :size => 3 %&gt; @@ -1165,16 +1231,24 @@ </tr> <tr> <td class="directive"><a href="#mv_elsif">mv:elsif</a></td> <td>Used in conjunction with the <span class="directiveName">mv:if</span> directive to allow you to create <code>if... elsif... end</code> blocks</td> </tr> +<tr> +<td class="directive"><a href="#mv_eval">mv:eval</a></td> +<td>Inserts an rhtml evaluation expression for the attribute value prior to this element</td> +</tr> <!-- f --> <tr> <td class="directive"><a href="#mv_form">mv:form</a></td> -<td>Replaces the start and end tags of this element using the Rails <code>form_tag</code> and <code>form_tag</code> helpers</td> +<td>Replaces the start and end tags of this element using the Rails <code>form_tag</code> block helper and a closing form tag</td> </tr> +<tr> +<td class="directive"><a href="#mv_form_remote">mv:form_remote</a></td> +<td>Replaces the start and end tags of this element using the Rails <code>form_remote_tag</code> helper and a closing form tag for Ajax-enabled form submission using the Prototype library</td> +</tr> <!-- g --> <tr> <td class="directive"><a href="#mv_generate">mv:generate</a></td> <td>Generate output containing this element and its children</td> @@ -1242,10 +1316,18 @@ Used on <code>&lt;a&gt;</code> link elements )</span> </td> </tr> <tr> +<td class="directive"><a href="#mv_link_to_function">mv:link_to_function</a></td> +<td>Replaces this element using the Rails <code>link_to_function</code> helper which creates a link which calls a JavaScript function. +<span class="explanation">( +Used on <code>&lt;a&gt;</code> link elements +)</span> +</td> +</tr> +<tr> <td class="directive"><a href="#mv_link_to_if">mv:link_to_if</a></td> <td>Replaces this element using the Rails <code>link_to_if</code> helper <span class="explanation">( Used on <code>&lt;a&gt;</code> link elements )</span> @@ -1334,26 +1416,32 @@ <div id="pageFooter"> <div> &middot;&nbsp; <a href="./index.html">Doc Home</a> &nbsp;|&nbsp; +<a href="./about.html">About</a> +&nbsp;|&nbsp; <a href="./installation.html">Installation</a> &nbsp;|&nbsp; <a href="./configuration.html">Configuration</a> &nbsp;|&nbsp; <a href="./guide.html">Usage</a> &nbsp;|&nbsp; <a href="./directives.html">Directives</a> -&nbsp;&nbsp; -<a href="./media_list.html">Media (Videos/Illustrations)</a> +&nbsp;|&nbsp; +<a href="./developer.html">Developers</a> +&nbsp;|&nbsp; +<a href="./media_list.html">Screencasts</a> &nbsp;&middot; </div> <table summary="layout area"> <tbody> <tr> <td class="copyright">&copy;&nbsp;Copyright MasterView 2006</td> <td class="validators"> - <a href="http://validator.w3.org/check/referer"><img src="http://www.w3.org/Icons/valid-xhtml10" title="Valid XHTML 1.0!" alt="Valid XHTML 1.0!" /></a> + <a href="http://validator.w3.org/check/referer"><img + src="http://www.w3.org/Icons/valid-xhtml10" class="w3c_validator" + title="Valid XHTML 1.0!" alt="Valid XHTML 1.0!" /></a> </td> </tr> </tbody> </table> </div> \ No newline at end of file