
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
maudite (moe-DEET) is a templating system using template literals. It returns a stream of buffers, or a string, for sending the resulting data to its destination.
maudite is pretty quick
A single function is exported, which acts as a template tag. This tag returns a function taking in a context object, which is then passed to any functions that are inlined into the template literal.
const m = require('maudite');
const template = m`Hello, ${c=>c.name}!\n`;
template({name: 'World'}).pipe(process.stdout);
// Hello, World!
Your inlined functions can return a buffer or a string or another template, and these will be sent to the stream. This means you can do any kind of conditional logic you want to determine what to render.
As a shortcut, you can simply put a property name (as a string that's parsed
with deep-access) for the context object, rather than a function accessing it.
const m = require('maudite');
const template = m`Hello, ${'name'}!\n`;
template({name: 'World'}).pipe(process.stdout);
// Hello, World!
You can also use the special m.each function to iterate over arrays in your
context object.
const m = require('maudite');
const template = m`Hello,${m.each('things', m` Thing ${c=>c.name}`)}!\n`;
template({
things: [
{name: '1'},
{name: '2'}
]
}).pipe(process.stdout);
// Hello, Thing 1 Thing 2!
The first argument to m.each is a context accessor string (see Accessing
Properties, below), giving the property that is an array to iterate over. The
next argument is a template to apply to each element of the array.
To return a compiled and ready-to-go string, rather than a stream, just call the
asString function on the template, passing in the context object.
const m = require('maudite');
const template = m`Hello, ${'name'}!\n`;
console.log(template.asString({name: 'World'}));
// Hello, World!
For both inline values (like ${'foo'}) and for the first argument to m.each,
strings can be used to access properties of the context object. These are
dot-separated strings that are compatible with their usage in [deep-access][].
In addition, you can use the @ symbol to refer to the current context object.
Here's an example, where the context object passed in is the string `'World':
const m = require('maudite');
const template = m`Hello, ${'@'}!\n`;
console.log(template.asString('World'));
// Hello, World!
See LICENSE.txt
FAQs
streaming templates using template literals
We found that maudite demonstrated a not healthy version release cadence and project activity because the last version was released 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

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.