Getting Started
Follow the instructions below to install TemplateDX in your app.
Install TemplateDX
Install with npm:
npm install @puzzlet/templatedx
or yarn:
yarn add @puzzlet/templatedx
Use TemplateDX
Loader (Recommended):
Use our webpack loader. Then import pre-parsed Template files directly.
import { transform } from '@puzzlet/templatedx';
import MyTemplate from './my-template.mdx';
...
const props = { name: 'Jim' };
const result = stringify(await transform(MyTemplate, props));
Node
import { transform, stringify, load } from '@puzzlet/templatedx';
const run = async (path: string) => {
const mdx = await load('./example.mdx');
const props = { name: 'Jim' };
return stringify(await transform(parsed, myProps));
}
run();