Template rendering services for Mixcore SDK. Provides utilities for dynamic content generation from templates.
- Multiple template engines (Handlebars, EJS, etc.)
- Layout and partial support
- Custom template helpers
- Async rendering
- Framework-agnostic implementation
npm install @mixcore/template
# or
pnpm add @mixcore/templateimport { TemplateService } from '@mixcore/template';
const templateService = new TemplateService();
// Render template with data
const html = await templateService.render('welcome', {
name: 'User',
date: new Date()
});templateService.registerHelper('formatDate', (date) => {
return new Intl.DateTimeFormat().format(date);
});- Handlebars (.hbs)
- EJS (.ejs)
- HTML with embedded expressions
- Plain text templates
| Method | Description |
|---|---|
render(template, data) |
Renders template with data |
registerHelper(name, fn) |
Adds custom helper |
getTemplate(name) |
Gets compiled template |
precompile(templates) |
Precompiles for performance |
This package works with all JavaScript frameworks. See the main README for framework-specific integration examples.
// Example: Using with SvelteKit
import { TemplateService } from '@mixcore/template';
const templateService = new TemplateService();
// Render template in Svelte component
$: rendered = templateService.render('welcome', {
name: 'User',
date: new Date()
});- @mixcore/api: API client integration
- @mixcore/file: File handling for templates
Mixcore Community License (MCL). See LICENSE for details.