Note that there are some explanatory texts on larger screens.

plurals
  1. PORouting helpers in Jade views (Locomotive framework)
    primarykey
    data
    text
    <p>I'm just starting with Node.js and decided to go for <a href="http://locomotivejs.org/" rel="nofollow">Locomotive</a>. I'm very pleased with the functionality it offers, and the pretty exhaustive <a href="http://locomotivejs.org/guide/" rel="nofollow">documention</a> provided. Still, I don't get how I'm supposed to use the "reverse routing" functionality. In the <a href="http://locomotivejs.org/guide/routing/" rel="nofollow">routing section of the doc</a> the helpers methods are mentioned but I don't understand how to use them inside my Jade views. Here are relevant code samples:</p> <p><strong>routes.js</strong></p> <pre><code>module.exports = function routes() { this.match('myroute', 'myroute#main', {as: 'myroute'}); } </code></pre> <p><strong>controller/myroute_controller.js</strong></p> <pre><code>var Controller = require('locomotive').Controller; var myrouteController = new Controller(); myrouteController.main = function() { this.render(); } module.exports = myrouteController; </code></pre> <p><strong>views/myroute/main.jade</strong></p> <pre><code>doctype 5 html body p the path that lead here is #{myroutePath()}. </code></pre> <p>I'm expecting the <code>myroutePath()</code> to be automatically available in main.jade, and it seems to be declared, but when I render the view, the server displays this error: <code>Object #&lt;Object&gt; has no method 'urlFor'</code> near my call to <code>myroutePath()</code>. </p> <p>My guess is <code>myroutePath()</code> uses <code>urlFor()</code> internally but this last method isn't available in my view. How am I supposed to use Locomotive's <em>reverse routing</em> ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload