
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
@braid-design-system/source.macro
Advanced tools
A [Babel macro][babel-plugin-macros] for authoring code snippets as code.
@braid-design-system/source.macro
A Babel macro for authoring code snippets as code.
In Braid, documentation is authored as code. Rather than writing snippets and code examples as strings, the source macro enables them to be written as code instead. The first argument passed to the macro will be returned both as a string and as the original value inside an object:
import source from '@braid-design-system/source.macro';
const result = source(<div>Hello world</div>);
// Returns { code: '<div>Hello world</div>', value: <div>Hello world</div> }
This macro enables several capabilities that are not easily achievable with snippets:
Install @braid-design-system/source.macro
:
npm install --save-dev @braid-design-system/source.macro
Install and configure babel-plugin-macros
:
npm install --save-dev babel-plugin-macros
// babel.config.js
module.exports = {
plugins: ['babel-plugin-macros'],
};
The source macro supports the following configuration options:
// babel.config.js
module.exports = {
plugins: [
[
'babel-plugin-macros',
{
source: {
// Whether to return a code string and the original value in an object, or just the code string. Defaults to `false`.
codeOnly: true,
// Whether to format the code string using Prettier. Defaults to `true`.
formatWithPretteir: false,
},
},
],
],
};
react-element-to-jsx-string
is a library that converts JSX elements to strings, but it cannot serialize functions, and the formatting of the resulting string is subpar relative to Prettier.
FAQs
A [Babel macro][babel-plugin-macros] for authoring code snippets as code.
The npm package @braid-design-system/source.macro receives a total of 282 weekly downloads. As such, @braid-design-system/source.macro popularity was classified as not popular.
We found that @braid-design-system/source.macro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.