Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

Allow 'include' to work in a .pug file, for a .pug file #13

Closed
retrone opened this issue Mar 23, 2016 · 10 comments
Closed

Allow 'include' to work in a .pug file, for a .pug file #13

retrone opened this issue Mar 23, 2016 · 10 comments

Comments

@retrone
Copy link

retrone commented Mar 23, 2016

When I have a .pug file, I can't include external .pug files, without getting an error. I can include a .jade file from a source .pug file without issue. Going to assume for now, that we shouldn't migrate extensions over to .pug, even though 2/3rd of the renaming seems to be done?

The associated error happens on an include of anything other than a .jade file, including non-existent files, .txt files, etc.:

TypeError: Cannot read property 'replace' of undefined
   at before (node_modules/pug-linker/index.js:104:48)
   at walkAST (node_modules/pug-walk/index.js:13:26)
   at node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (node_modules/pug-walk/index.js:20:29)
   at applyIncludes (node_modules/pug-linker/index.js:102:10)
   at link (node_modules/pug-linker/index.js:21:9)
   at compileBody (node_modules/pug/lib/index.js:84:11)
   at Object.exports.compile (node_modules/pug/lib/index.js:164:16)
   at handleTemplateCache (node_modules/pug/lib/index.js:137:25)
   at Object.exports.renderFile (node_modules/pug/lib/index.js:331:10)
   at Object.exports.renderFile (node_modules/pug/lib/index.js:321:21)
   at View.exports.__express [as engine] (node_modules/pug/lib/index.js:368:11)
     ...
@matutter
Copy link

I also get this same error.

The exact line of code is,
replace({type: 'Text', val: node.file.str.replace(/\r/g, '')});
there is no 'str' property on 'file'

@matutter
Copy link

The actual bug is with the version of pug-loader. You should just update that to the latest or fix the regex looking for '.jade' at the end of the path after the 'include' token.

@gh0sTedBuddy
Copy link

not really sure what to do know, get the same error within my expressjs with pug as view engine. deinstalling pug and reinstallig jade again... sadly.

@matutter
Copy link

matutter commented May 19, 2016

Since I updated the latest npm install pug@2.0.0-alpha7 I haven't had an issue. Checked your version lately?

NOTE: I realized when downloading with an out-dated npm the wrong version of certain modules with the package-version-prefix ^ were downloaded, thus causing this issue.

@ForbesLindesay
Copy link
Member

This looks like it's just an out of date version of pug.

@johnb8005
Copy link

it seems npm install installs an old version by default ...

@Gliptal
Copy link

Gliptal commented Jul 18, 2016

@jboissard It definitely does. How do i force the newest version?

@johnb8005
Copy link

johnb8005 commented Jul 20, 2016

try npm install pug@2.0.0-beta4 --save @Gliptal

@TimothyGu
Copy link
Member

@jboissard, @Gliptal, 2.0.0-alpha6 is not the newest version anymore. See http://npm.im/pug, 2.0.0-beta4 is.

@johnb8005
Copy link

@TimothyGu updated my comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants