Reputation: 1556
I have following folder structure (simplified):
project
- app.js
- views
- index.jade
- layout.jade
- public
...
I want to generate an index.html file from index.jade and use the following command in my Terminal (Mac OS X):
jade < index.jade > index.html
However I receive an error saying:
/usr/local/lib/node_modules/jade/lib/runtime.js:231
throw err;
^
Error: Jade:1
> 1| extends ./layout
2|
3| block mainContent
4| center
the "filename" option is required to use "extends" with "relative" paths
at Parser.resolvePath (/usr/local/lib/node_modules/jade/lib/parser.js:464:13)
at Parser.parseExtends (/usr/local/lib/node_modules/jade/lib/parser.js:483:21)
at Parser.parseExpr (/usr/local/lib/node_modules/jade/lib/parser.js:221:21)
at Parser.parse (/usr/local/lib/node_modules/jade/lib/parser.js:122:25)
at parse (/usr/local/lib/node_modules/jade/lib/index.js:102:21)
at Object.exports.compile (/usr/local/lib/node_modules/jade/lib/index.js:172:16)
at ReadStream.<anonymous> (/usr/local/lib/node_modules/jade/bin/jade.js:144:21)
at ReadStream.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)
I tried editing the line which causes the error in index.jade to:
extends layout
and
extends layout.jade
and
extends ./layout.jade
Any idea how I could fix this?
Upvotes: 1
Views: 2723
Reputation: 15101
You have to set -p
option:
jade -p src/index.jade < src/index.jade > build/index.html
Be careful! Jade drops last component of
-p
argument to concatenate with relative path.
Upvotes: 0
Reputation: 1411
if use "extend" or "include", the filename option must be used.
--filename "/absulute/path/to/your-file.jade"
Upvotes: 1
Reputation: 193
You get the error because you are trying with
jade < index.jade > index.html
so jade have troubles finding the path (not sure why I think this is an issue) but if you try
jade < index.jade >
everything will be smooth.
or maybe try some automation with http://gulpjs.com/
Upvotes: 0