I want to redo my blog but my code below seems to be returning [function]
whenever I console.log it. Yes it is the correct path, and it used to work before I updated jade but not anymore.
post.stub = jade.compile(
fs.readFileSync(__dirname + '/blog/' + p + '/stub.jade')
)
How do I fix this so that console.log(post.stub)
will return my :markdown present in the jade file instead of [function]
?
Thanks in advance.
Updated answer:
post.stub = jade.compile(
fs.readFileSync(__dirname + '/blog/' + p + '/stub.jade')
)({})
This is how jade and all similar template systems work. There are 2 steps:
So if your template doesn't need any context data, just invoke it with an empty object (probably null/undefined would also work fine):
post.stub = jade.compile(
fs.readFileSync(__dirname + '/blog/' + p + '/stub.jade')
)({})
See also the jade javascript API docs.