PageRenderTime 30ms CodeModel.GetById 1ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/classes/ActsCrummy/BreadcrumbsHelper.html

http://acts-crummy.googlecode.com/
HTML | 186 lines | 137 code | 46 blank | 3 comment | 0 complexity | 1d140b01819279a19825ae9bfc6a490e MD5 | raw file
  1<?xml version="1.0" encoding="iso-8859-1"?>
  2<!DOCTYPE html 
  3     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  4     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5
  6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  7<head>
  8  <title>Module: ActsCrummy::BreadcrumbsHelper</title>
  9  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 10  <meta http-equiv="Content-Script-Type" content="text/javascript" />
 11  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 12  <script type="text/javascript">
 13  // <![CDATA[
 14
 15  function popupCode( url ) {
 16    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
 17  }
 18
 19  function toggleCode( id ) {
 20    if ( document.getElementById )
 21      elem = document.getElementById( id );
 22    else if ( document.all )
 23      elem = eval( "document.all." + id );
 24    else
 25      return false;
 26
 27    elemStyle = elem.style;
 28    
 29    if ( elemStyle.display != "block" ) {
 30      elemStyle.display = "block"
 31    } else {
 32      elemStyle.display = "none"
 33    }
 34
 35    return true;
 36  }
 37  
 38  // Make codeblocks hidden by default
 39  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
 40  
 41  // ]]>
 42  </script>
 43
 44</head>
 45<body>
 46
 47
 48
 49    <div id="classHeader">
 50        <table class="header-table">
 51        <tr class="top-aligned-row">
 52          <td><strong>Module</strong></td>
 53          <td class="class-name-in-header">ActsCrummy::BreadcrumbsHelper</td>
 54        </tr>
 55        <tr class="top-aligned-row">
 56            <td><strong>In:</strong></td>
 57            <td>
 58                <a href="../../files/lib/breadcrumbs_helper_rb.html">
 59                lib/breadcrumbs_helper.rb
 60                </a>
 61        <br />
 62            </td>
 63        </tr>
 64
 65        </table>
 66    </div>
 67  <!-- banner header -->
 68
 69  <div id="bodyContent">
 70
 71
 72
 73  <div id="contextContent">
 74
 75    <div id="description">
 76      <p>
 77This module is mixed into ActionView::Base to provide the ability to render
 78breadcrumbs using the structure from the models.
 79</p>
 80
 81    </div>
 82
 83
 84   </div>
 85
 86    <div id="method-list">
 87      <h3 class="section-bar">Methods</h3>
 88
 89      <div class="name-list">
 90      <a href="#M000001">render_breadcrumbs</a>&nbsp;&nbsp;
 91      </div>
 92    </div>
 93
 94  </div>
 95
 96
 97    <!-- if includes -->
 98
 99    <div id="section">
100
101
102    <div id="constants-list">
103      <h3 class="section-bar">Constants</h3>
104
105      <div class="name-list">
106        <table summary="Constants">
107        <tr class="top-aligned-row context-row">
108          <td class="context-item-name">DEFAULT_BREADCRUMB_SEPARATOR</td>
109          <td>=</td>
110          <td class="context-item-value">' &amp;gt; '</td>
111        </tr>
112        </table>
113      </div>
114    </div>
115
116
117
118      
119
120
121    <!-- if method_list -->
122    <div id="methods">
123      <h3 class="section-bar">Public Instance methods</h3>
124
125      <div id="method-M000001" class="method-detail">
126        <a name="M000001"></a>
127
128        <div class="method-heading">
129          <a href="#M000001" class="method-signature">
130          <span class="method-name">render_breadcrumbs</span><span class="method-args">(child, options = {})</span>
131          </a>
132        </div>
133      
134        <div class="method-description">
135          <p>
136Renders breadcrumbs up the model hierarchy starting with <tt>child</tt>,
137creating a link for each item, and returning the result as a string. It
138works by selecting the return value of the method parent from each model
139object. Each parent value is expected to be an instance of a model so that
140a link can be rendered. As a convenience, the method
141ActiveRecord::Base.is_child_to is provided so that the existing model does
142not need to be altered to use breadcrumbs.
143</p>
144<p>
145The only allowable currently is <tt>:level</tt>, which is an optional
146integer to limit the number of parent links displayed to.
147</p>
148          <p><a class="source-toggle" href="#"
149            onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
150          <div class="method-source-code" id="M000001-source">
151<pre>
152    <span class="ruby-comment cmt"># File lib/breadcrumbs_helper.rb, line 19</span>
15319:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render_breadcrumbs</span> <span class="ruby-identifier">child</span>, <span class="ruby-identifier">options</span> = {}
15420:       <span class="ruby-identifier">i</span>, <span class="ruby-identifier">level</span> = <span class="ruby-value">0</span>, (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:level</span>] <span class="ruby-operator">||</span> <span class="ruby-value">-1</span>)
15521:       <span class="ruby-identifier">urls</span> = [<span class="ruby-identifier">describe_model</span>(<span class="ruby-identifier">child</span>)]
15622:       <span class="ruby-identifier">parent</span> = <span class="ruby-identifier">child</span>
15723: 
15824:       <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:parent</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">level</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">parent</span>)
15925:         <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
16026:         <span class="ruby-comment cmt"># if block_given?</span>
16127:         <span class="ruby-identifier">urls</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">parent_link</span>(<span class="ruby-identifier">parent</span>, <span class="ruby-identifier">options</span>))
16228:         <span class="ruby-comment cmt"># else</span>
16329:         <span class="ruby-comment cmt">#   urls.unshift(parent_link(parent))</span>
16430:         <span class="ruby-comment cmt"># end          </span>
16531:       <span class="ruby-keyword kw">end</span>
16632: 
16733:       <span class="ruby-identifier">urls</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:separator</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DEFAULT_BREADCRUMB_SEPARATOR</span>)
16834:     <span class="ruby-keyword kw">end</span>
169</pre>
170          </div>
171        </div>
172      </div>
173
174
175    </div>
176
177
178  </div>
179
180
181<div id="validator-badges">
182  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
183</div>
184
185</body>
186</html>