Skip to content

A markdown engine for Express that allows lightweight {{templating}}

Notifications You must be signed in to change notification settings

kyledetella/markdown-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

{{markdown}}

Build Status

A lightweight markdown engine for Express.

Development

Install

$ npm i

Test

$ npm t

Example

app.js

'use strict';

var express = require('express');
var markdownEngine = require('./util/markdown-engine');

var app = express();

app.engine('md', markdownEngine.configure());

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'md');

...

views/layout.html

<!DOCTYPE html>
<html>
  <head>
    <title>{{title}}</title>
  </head>
  <body>
    {{body}}
  </body>
</html>

Templating

Templates are written using Markdown and provide basic templating features.

My middle name is {{name}}
res.render('template', { name: 'danger' });
My middle name is danger

Partials

Partials can be included by using the following syntax:

{{> partial}}
{{> path/to/partial}}

By default, partials are expected to be located in the views/partials/ directory.

Caching

Template caching is enabled only in production. NODE_ENV=production

API

configure: Function

The configure call accepts an Object as an argument. It is not required, but allows you to specify a basePath for the engine. By default partials and templates are expected to live in the views directory in the root of your project. If your this directory happens to be placed somewhere else, use basePath to define it.

app.engine('md', markdownEngine.configure({basePath: __dirname});

About

A markdown engine for Express that allows lightweight {{templating}}

Resources

Stars

Watchers

Forks

Packages

No packages published