ppsreejith / dot-mustache

Dot notation parser for Mustache

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DotMustache

Allows you to access arrays and objects via dot notation.

const {parser} = require('dot-mustache');
parser('body.text.crit.[words,something.here]', {
  body: {
    text: [{
      crit: {
        words: ['This works', 'This too'],
        something: {
          here: 'here this works',
        },
      },
    }, {
      crit: [{
        words: 'still works',
        something: {
          here: 'here this works too',
        },
      }],
    }],
  },
});

This code snippet returns

[{
  'words': ['This works', 'This too'],
  'something.here': 'here this works'
} {
  'words': 'still works',
  'something.here': 'here this works too'
}]

About

Dot notation parser for Mustache


Languages

Language:JavaScript 100.0%