
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
Safe HTML tree structures for Markdown and content-driven apps.
{
"div": [
{ "h1": "Hello world" },
{ "p": "Welcome to treebark templates" }
]
}
Output:
<div>
<h1>Hello world</h1>
<p>Welcome to treebark templates</p>
</div>
Learn more at the Homepage | Try it now in the Playground
npm install treebark
import { renderToString } from 'treebark';
// Simple example
const html = renderToString({
template: {
div: {
class: "greeting",
$children: ["Hello {{name}}!"]
}
},
data: { name: "World" }
});
console.log(html);
// Output: <div class="greeting">Hello World!</div>
import { renderToDOM } from 'treebark';
// Create DOM elements directly
const fragment = renderToDOM({
template: {
div: {
class: "greeting",
$children: ["Hello {{name}}!"]
}
},
data: { name: "World" }
});
// Append to document
document.body.appendChild(fragment);
Treebark supports tree shaking for optimal bundle sizes. Import only what you need:
// Only import the string renderer (smaller bundle for Node.js SSR)
import { renderToString } from 'treebark/string';
// Only import the DOM renderer (for browser-only apps)
import { renderToDOM } from 'treebark/dom';
// Or import both from the main entry
import { renderToString, renderToDOM } from 'treebark';
Modern bundlers like Vite, Webpack, and Rollup will automatically remove unused code from your bundle.
renderToString(input, options?)Renders a template to an HTML string.
Parameters:
input: TreebarkInput - Object with template and optional dataoptions?: RenderOptions - Optional rendering options (indentation, etc.)Returns: string - Generated HTML
renderToDOM(input, options?)Renders a template to DOM nodes (browser only).
Parameters:
input: TreebarkInput - Object with template and optional dataoptions?: RenderOptions - Optional rendering optionsReturns: DocumentFragment - DOM fragment containing rendered nodes
For comprehensive examples, documentation, and advanced features, see the main Treebark repository.
MIT
FAQs
Safe HTML tree structures for Markdown and content-driven apps
The npm package treebark receives a total of 4 weekly downloads. As such, treebark popularity was classified as not popular.
We found that treebark demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.