-
-
Save shakirahas/859ea29cf0e232499db8518ee884b2ff to your computer and use it in GitHub Desktop.
Using jade template to render rss-feed in nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doctype xml | |
rss(version='2.0') | |
channel | |
title= feed.title | |
description= feed.description | |
link= feed.link | |
language= feed.en | |
for item in posts | |
item | |
title= item.title | |
pubDate= item.pubDate | |
description= item.description | |
link= item.canonicalUrl | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var jade = require('jade'); | |
var html = fs.readFileSync('./rss.jade').toString(); | |
var options = { | |
feed: { | |
title: 'feed title', | |
description: 'feed description', | |
link: 'http://example.org/rss.xml', | |
language: 'en' | |
}, | |
posts: [{ | |
title: 'post1 title', | |
description: 'post1 summary', | |
canonicalUrl: 'http://example.org/post1', | |
pubDate: (new Date()).toGMTString() | |
}] | |
}; | |
jade.render(html, options, function (err, html) { | |
if (err) { | |
throw err; | |
} | |
console.info(html); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment