md4template

0.0.4 • Public • Published

#md4template

Installation

$ npm install md4template

Feature

  • Parsing a markdown file on file system.
  • Help to insert html code (parsed from markdown) to template.

Usage

var md4tpl = require('md4template');

//default encoding - utf8
md4tpl.config['encoding'] = 'utf8';

//default prefix - ''
//prefix for key of returned array from 'parseDir'.
md4tpl.config['prefix'] = 'md_';

//parse a markdown file.
parsed_str = md4tpl.parseFile(file_path);

//parse markdown files in a directory.
parsed_list = md4tpl.parseDir(dir_path);

//if there are files 'index.md', 'work.md' in dir_path..
//'md_' is prefix.
//parsed_list = { "md_index" : [html code of index.md], "md_work" : [html code of md_work.md] }

Example

md4template with express, ejs.

expressApp/public/markdown/index/

  • current.md

  • favorite.md

  • work.md


  • route/index.js
...

var md4tpl = require('md4template');

exports.index = function(req, res){
  res.render('index', md4tpl.parseDir(path.join(__dirname, '../public', 'markdown', 'index')));
};

...
  • view/index.ejs
...

<div class="page-region">
	<div class="page-region-content">
		<div>
			<%- current %>
		</div>
		<div>
			<%- favorite %>
		</div>
		<div>
			<%- work %>
		</div>
	</div>
</div>

...

Readme

Keywords

none

Package Sidebar

Install

npm i md4template

Weekly Downloads

0

Version

0.0.4

License

BSD

Last publish

Collaborators

  • angdev