Using filters in Jade

Jade filters are powerful features which enable the users to use different markups inside Jade templates. Their primary use is to make templates even more succinct by enabling the user to use the appropriate tool for a particular section of the template.

In this recipe, we're going to use Jade filters to embed markdown inside our template and explain how filters work.

Getting ready

The client-side version of Jade https://github.com/visionmedia/jade is found in the jade.js file and does not support markdown filters out of the box. To add support for markdown we need edit this file and find the line that starts defining the markdown filter:

 markdown: function(str){ var md; // support markdown / discount try { …. } str = str.replace(/\\n/g, ...

Get HTML5 Data and Services Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.