@xmark/transform-template
v0.24.0
Published
xmark transform plugin to apply a template on the hast and front matter on the pipeline
Downloads
4
Readme
@xmark/transform-template
xmark plugin to render templates on hast and front matter, and return hast/html to later processing
Usage
yarn add @xmark/core @xmark/transform-template
const XMark = require('@xmark/core');
const render = require('@xmark/transform-template');
const xmark = XMark();
xmark.useTransform(render, {
template: '<h1>{{title}}</h1><h2>{{author}}</h2><div>{{{body}}}</div>',
});
const hast = xmark.toHAST('---\ntitle: "title"\nauthor: "author"\n---\n# heading 1');
const html = xmark.toHTML('---\ntitle: "title"\nauthor: "author"\n---\n# heading 1');
expect(hast.children[0].tagName).toEqual('html');
expect(html).toEqual(
'<html><head></head><body><h1>title</h1><h2>author</h2><div><h1>heading 1</h1></div></body></html>'
);