@bangstack/interpolate
v1.0.0
Published
Dynamic content interpolation for journeys and demos with random data generation
Maintainers
Readme
@bangstack/interpolate
Dynamic content interpolation for journeys and demos with random data generation.
Installation
npm install @bangstack/interpolateQuick Start
import { interpolate, random, createInterpolationContext } from '@bangstack/interpolate';
// Simple interpolation
const text = interpolate('Hello, {{ name }}!', { name: 'World' });
// => 'Hello, World!'
// Random data generation
const email = random.email(); // => '[email protected]'
const name = random.name(); // => 'Jane Doe'
const id = random.uuid(); // => '550e8400-e29b-41d4-a716-446655440000'
const projectName = random.projectName(); // => 'Cosmic Nebula'
// Context for capturing and reusing values
const ctx = createInterpolationContext();
ctx.capture('userId', '123');
const message = interpolate('User {{ context.userId }} logged in', ctx.getContext());
// => 'User 123 logged in'Available Expressions
| Expression | Description |
|------------|-------------|
| {{ random.name }} | Full name |
| {{ random.email }} | Email address |
| {{ random.uuid }} | UUID v4 |
| {{ random.projectName }} | Project name |
| {{ random.number(1, 100) }} | Random number in range |
| {{ now }} | Current timestamp |
| {{ today }} | Today's date (YYYY-MM-DD) |
| {{ context.varName }} | Captured context value |
License
MIT
