node.jsexpresspugpugjs

Including pug file causes error but jade works fine


Running into a weird issue here. I have a pretty basic jade/pug include going on here:

extends base.pug

block vars
    - var title = 'Home'

block body
    header
        include ./includes/header.pug

A quick note, just using extends base (without the extension) just doesn't work. But this include gives the following error:

TypeError: Cannot read property 'replace' of undefined
   at before (/var/node/website/node_modules/pug-linker/index.js:104:48)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:13:26)
   at /var/node/website/node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:33:21)
   at /var/node/website/node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29)
   at /var/node/website/node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29)
   at applyIncludes (/var/node/website/node_modules/pug-linker/index.js:102:10)
   at link (/var/node/website/node_modules/pug-linker/index.js:21:9)
   at compileBody (/var/node/website/node_modules/pug/lib/index.js:84:11)
   at Object.exports.compile (/var/node/website/node_modules/pug/lib/index.js:164:16)

But changing that to :

extends base.pug

block vars
    - var title = 'Home'

block body
    header
        include ./includes/header.jade

Works perfectly fine. The contents of header.jade and header.pug are the exact same so I am a bit perplexed here. Some help would be appreciated.

Thanks,

PS: Searching did reveal: https://github.com/pugjs/pug-linker/issues/13 - seems to be a bug but not sure how this could be.


Solution

  • So it looks like pug isn't really ready for primetime YET! Look forward to when it is but using jade instead of pug solves the issue, just rename everything to .jade.