API - sbekoe/maskJS GitHub Wiki

API

Defining the Syntax

Defining Logic

Registering Templates

Render Templates

Features

Self explaining example

The <template> string registered with Mask.register(<template>,[conf]).

/*
  name:example
  syntax:mustache
*/
{list}
list with {item.length} elements:
  {item}{i}: {text}{/item}
{/list}

The <context> to populate a template with.

{
  list:{
    item:[
      {text: 'item a'},
      {text: 'item b'},
      {text: 'item c'}
    ]
  }
}

The output produced by Mask.render('example',<context>).

list with 3 elements:
  1: item a
  2: item b
  3: item c

Automated organization of templates

Each nested template is registered as independed template in the namespace of the parent template. So after registrating the the template above, the list and item could be rendered apart with Mask.render('example.list') and Mask.render('example.list.item').

resolving data paths/namespaces while rendering

⚠️ **GitHub.com Fallback** ⚠️