Reputation: 613
I want to parse Jade coming from a database. Like from a blog post, where the body is in Jade. Right now I can parse HTML from Jade using:
!= post.body
It works for HTML, but doesn't for Jade. Is there a way to parse the Jade from an external source?
Upvotes: 0
Views: 223
Reputation: 2228
If you are trying to compile text-string as Jade template (post body from database):
// node.js
// https://github.com/visionmedia/jade/#a5
var jade = require('jade');
var template = 'h1 Hi';
var options = {};
var htmlFunc = jade.compile(template, options);
var locals = {};
var html = htmlFunc(locals);
// now you can pass `html` to your blog post layout.
h1!= require('jade').compile('span Hi')();
Upvotes: 2