Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics (2015) Using Templates with Express Scaffolding Your Project’s Templates - adding β€œpartials”

Anthony c
Anthony c
20,907 Points

Issue with _nav template

I'm getting the following error in my browser:

Error: /Users/MYNAME/Desktop/projects/express-basics/src/templates/partials/_nav.jade:7
   5|             button.navbar-toggle.collapsed(type='button', data-toggle='collapse', data-target='#bs-example-navbar-collapse-1')
   6|                 span.sr-only Toggle navigation
 > 7|                 |
   8|                 span.icon-bar
   9|                 |
   10|                 span.icon-bar

It seems like there is some issue with line 7 in my nav partial. When I comment out "include .partials/_nav.jade" from layout.jade -- everything works.

This is the jade file:

nav#mainNav.navbar.navbar-default.navbar-fixed-top
    .container-fluid
        // Brand and toggle get grouped for better mobile display
        .navbar-header
            button.navbar-toggle.collapsed(type='button', data-toggle='collapse', data-target='#bs-example-navbar-collapse-1')
                span.sr-only Toggle navigation
                |
                span.icon-bar
                |
                span.icon-bar
                |
                span.icon-bar
            |
            a.navbar-brand.page-scroll(href='/') FitLog.io
        // Collect the nav links, forms, and other content for toggling
        #bs-example-navbar-collapse-1.collapse.navbar-collapse
            ul.nav.navbar-nav.navbar-right
                li
                    a(href='/blog') Blog
                li
                    a.page-scroll(href='#about') About
                li
                    a.page-scroll(href='#services') Services
                |
                li
                    a.page-scroll(href='#portfolio') Portfolio
                |
                li
                    a.page-scroll(href='#contact') Contact
                // /.navbar-collapse
                // /.container-fluid

Is it an issue with the "Toggle navigation" word? I don't see what's happening.

1 Answer

This is a very annoying problem.

It has something to do with those pipe symbols or/and your IDE or/and your indentation settings. When I clone the Repo everything works just fine and I have no errors. But when I copy/paste the code or write it by myself it doesn't work anymore (ERROR: unexpected text |) even though everything is set up the same. Totally weird.

This worked for me: Delete all pipe symbols which have no text afterwards. In _nav.jade that should be all pipe symbols.

I could not see any difference in the rendered HTML.

Hope it works for you.