Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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:

        // Brand and toggle get grouped for better mobile display
            button.navbar-toggle.collapsed(type='button', data-toggle='collapse', data-target='#bs-example-navbar-collapse-1')
                span.sr-only Toggle navigation
            a.navbar-brand.page-scroll(href='/') FitLog.io
        // Collect the nav links, forms, and other content for toggling
                    a(href='/blog') Blog
                    a.page-scroll(href='#about') About
                    a.page-scroll(href='#services') Services
                    a.page-scroll(href='#portfolio') Portfolio
                    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.