Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@mixcore/template

Template rendering services for Mixcore SDK. Provides utilities for dynamic content generation from templates.

Features

  • Multiple template engines (Handlebars, EJS, etc.)
  • Layout and partial support
  • Custom template helpers
  • Async rendering
  • Framework-agnostic implementation

Installation

npm install @mixcore/template
# or
pnpm add @mixcore/template

Usage

Basic Example

import { TemplateService } from '@mixcore/template';

const templateService = new TemplateService();

// Render template with data
const html = await templateService.render('welcome', {
  name: 'User',
  date: new Date()
});

Custom Helpers

templateService.registerHelper('formatDate', (date) => {
  return new Intl.DateTimeFormat().format(date);
});

Supported Template Types

  • Handlebars (.hbs)
  • EJS (.ejs)
  • HTML with embedded expressions
  • Plain text templates

API Reference

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

Framework Integration

This package works with all JavaScript frameworks. See the main README for framework-specific integration examples.

Package-specific Usage

// 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()
});

Related Packages

License

Mixcore Community License (MCL). See LICENSE for details.