Note that there are some explanatory texts on larger screens.

plurals
  1. POReference error: "Tags is not defined"
    text
    copied!<p>I have manipulated the code in <a href="https://github.com/dtryon/clog" rel="nofollow">this application</a>, and put in a sidebar in the views/layout.jade file. In the sidebar I've cut/pasted the code for handling tags from views/index.jade:</p> <pre><code> ul.tags each tag in tags a(href='/tag/' + tag._id.toHexString()) li.tag= tag.name </code></pre> <p>The tags are fetched from the db as they should, and rendered out in the sidebar, however when I click on one of them (which should show a new page with all the posts tagged with the tag) I get an error message:</p> <pre><code>500 ReferenceError: ... layout.jade:10 8| p 9| ul.tags &gt; 10| each tag in tags 11| a(href='/tag/' + tag._id.toHexString()) 12| li.tag= tag.name tags is not defined </code></pre> <p>Here's the function that's called in the file "tagcontroller.js" (that's handling the logic for the tags):</p> <pre><code>app.get('/tag/:id', function(req, res){ model.Tag.findById(req.params.id, function (err, tag){ if (err) { console.log(err); // do something } var query = blogModel.BlogPost.find( { _id: { $in : tag.blogs } } ); query.where('date').lte(new Date()); query.exec(function (err, blogs) { if (err) { console.log(err); // do something } var query = model.Tag.find({}); query.exec(function (err, tags) { if (err) { console.log(err); // do something } res.render('tags/detail', { title: tag.name, blogs: blogs, tagList: tags, dateFormatter: dateFormatter }); }); }); }); }); </code></pre> <p>If I put back the code into views/index.jade, everything works fine. But I need to have it in layout.jade to be able to show it on every page, not only on Home (index.jade).</p> <p>I would really appreciate some help!</p>
 

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