Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Latest commit

 

History

History

templates

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@atlas.js/templates

This package contains an action which allows rendering a template language into the resulting html string. This is ideal for rendering email templates or simple web views into final html.

The rendering is done using consolidate.js - all template languages listed there are supported by this action - you only need to install the template package you wish to use.

Usage

Make sure you install the template package you want to use.

import { Atlas } from '@atlas.js/atlas'
import { Action as Templates } from '@atlas.js/templates'

const atlas = new Atlas({
  config: {
    actions: {
      templates: {
        engine: 'pug',
        templates: 'path/to/templates',
        extension: '.pug',
      },
    },
  },
})
atlas.action('templates', Templates)
await atlas.start()

// Render a template file located in the folder you specified via `templates` in the config and use
// the second argument as the locals for the template
const html = await atlas.actions.templates.render('password-reset', { user: 'abc', code: '123456' })

License

See the LICENSE file for information.