New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

composium

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

composium

Composium composition engine

latest
npmnpm
Version
0.99.7
Version published
Maintainers
1
Created
Source

Composium™

Ultra-fast, lightweight, general purpose composition engine for Node.js

$ npm i composium

Composium is an easily and incrementally adoptable ultra fast and lightweight general purpose composition engine that targets the Node.js platform as an NPM module.

  • Unopinionated
  • Open source
  • ISC licensed
  • Dependency free

Unlike templating engines, Composium does not require the use of a templating paradigm and supports advanced logic using ECMAScript and optionally Node.js modules.

  • Clear separation of presentation and logic
  • Full presentation and logic support in included templates

Quickstart

Contrived example referencing data with no logic:

const composium = require('composium')

let template = '<presentation>Hi <data>firstName</data>!</presentation>'
composium.loadTemplate('Hi Template', template)

let output = composium.compose('Hi Template', { firstName: 'Sam' })

Template format

Templates are comprised of a presentation tag and/or a script tag for logic and for explicit manipulation of the output.

<script>
    let name = (data.firstName) ? data.firstName | 'world'
</script>

<presentation>
    <p>Hello <variable>name</variable>!</p>
<presentation>

Presentation tag

The presentation tag contains a tag-based logicless template for merging copy with data and variables created in a corresponding script tag.

  • Required when script tag is absent
  • White space is preserved
  • Data and variable value encoding can be specified optionally with a profile

Quick guide

TagUse
data<data>name</data>
else<if condition="condition">...<else>...</else></if>
for<for each="item" in="items">...</for>
if<if condition="condition">...</if>
include<include>name</include>
variable<variable>name</variable

Script tag

The script tag contains ECMAScript for template logic and for optionally manipulating the output explicitly.

  • Required when presentation tag is absent

Any variable created in the script tag can be referenced by the variable tag in the presentation.

Quick guide

ObjectUse
datadata.property[.property] etc
includeinclude('templateName')
outputoutput.clear()
outputoutput.set('string')
outputoutput.toString()
profileprofile.property[.property] etc
requirerequire('moduleName')
workspaceworkspace.get('name')
workspaceworkspace.set('name', object)

Profile

The profile provides a mechanism for externalizing behavior for a single compose call.

  • A profile is not required
  • Encoding settings for data and variables (defaults to none)
  • Before/After compostion to optionally invoke specified template(s) by name
  • Properties can be referenced within logic to customize behavior

Quick guide

{
    name: 'Profile name',
    variableEncoding: 'none/xml/html',
    dataEncoding: 'none/xml/html',
    beforeComposition: ['Template name'],
    afterComposition: ['Template name'],
    properties: {
        samplePropertyName: 'samplePropertyValue'
    }
}

Coming soon!

  • Custom tags
  • Enhanced encoding support
  • Data and variable defaulting
  • Variable prefix whitelisting
  • More...

Keywords

composium

FAQs

Package last updated on 12 Jul 2019

Did you know?

Socket

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.

Install

Related posts