Permalink
Browse files

add nested optional to keys section

  • Loading branch information...
1 parent 356bff3 commit c8d9dbe3c0f8704bc33b7295d391d7fe1a56ee54 @kieran committed Mar 2, 2015
Showing with 13 additions and 2 deletions.
  1. +4 −2 index.html
  2. +2 −0 templates/routes/keys.haml
  3. +4 −0 templates/routes/keys1.coffee
  4. +3 −0 templates/routes/keys1.js
View
@@ -242,8 +242,10 @@ <h3>A simple example</h3>
<code class='output'># =>&#x000A;{&#x000A; controller: 'Products'&#x000A; action: 'index'&#x000A; method: 'GET'&#x000A;}&#x000A;</code></pre>
<div id='keys'>
<h3>Route keys</h3>
- <pre class='language-javascript'><code>router.match( '/products/:id', 'GET' )&#x000A; .to( 'Products.show' )&#x000A;&#x000A;router.match( '/profiles/:username', 'GET' )&#x000A; .to( 'Users.show' )&#x000A;&#x000A;// things enclosed in parens are optional&#x000A;router.match( '/products/:id(.:format)', 'GET' )&#x000A; .to( 'Products.show' )&#x000A;</code></pre>
- <pre class='language-coffeescript'><code>router&#x000A;.match '/products/:id', 'GET'&#x000A;.to 'Products.show'&#x000A;&#x000A;router&#x000A;.match '/profiles/:username', 'GET'&#x000A;.to 'Users.show'&#x000A;&#x000A;# things enclosed in parens are optional&#x000A;router&#x000A;.match '/products/:id(.:format)', 'GET'&#x000A;.to 'Products.show'&#x000A;</code></pre>
+ <pre class='language-javascript'><a class='btn btn-default' href='#try'>try it</a>
+ <code>router.match( '/products/:id', 'GET' )&#x000A; .to( 'Products.show' )&#x000A;&#x000A;router.match( '/profiles/:username', 'GET' )&#x000A; .to( 'Users.show' )&#x000A;&#x000A;// things enclosed in parens are optional&#x000A;router.match( '/products/:id(.:format)', 'GET' )&#x000A; .to( 'Products.show' )&#x000A;&#x000A;// optional segments are also nestable&#x000A;router.match( '/:controller(/:action(/:id))(.:format)', 'GET' )&#x000A;</code></pre>
+ <pre class='language-coffeescript'><a class='btn btn-default' href='#try'>try it</a>
+ <code>router&#x000A;.match '/products/:id', 'GET'&#x000A;.to 'Products.show'&#x000A;&#x000A;router&#x000A;.match '/profiles/:username', 'GET'&#x000A;.to 'Users.show'&#x000A;&#x000A;# things enclosed in parens are optional&#x000A;router&#x000A;.match '/products/:id(.:format)', 'GET'&#x000A;.to 'Products.show'&#x000A;&#x000A;# optional segments are also nestable&#x000A;router&#x000A;.match '/:controller(/:action(/:id))(.:format)', 'GET'&#x000A;</code></pre>
</div>
<div id='globs'>
<h3>Globs</h3>
@@ -1,10 +1,12 @@
#keys
%h3 Route keys
%pre.language-javascript
+ %a.btn.btn-default{href:'#try'} try it
%code
:preserve
#{File.read 'templates/routes/keys1.js'}
%pre.language-coffeescript
+ %a.btn.btn-default{href:'#try'} try it
%code
:preserve
#{File.read 'templates/routes/keys1.coffee'}
@@ -10,3 +10,7 @@ router
router
.match '/products/:id(.:format)', 'GET'
.to 'Products.show'
+
+# optional segments are also nestable
+router
+.match '/:controller(/:action(/:id))(.:format)', 'GET'
@@ -7,3 +7,6 @@ router.match( '/profiles/:username', 'GET' )
// things enclosed in parens are optional
router.match( '/products/:id(.:format)', 'GET' )
.to( 'Products.show' )
+
+// optional segments are also nestable
+router.match( '/:controller(/:action(/:id))(.:format)', 'GET' )

0 comments on commit c8d9dbe

Please sign in to comment.