dot-mustache

Dot notation for mustache

Usage no npm install needed!

<script type="module">
  import dotMustache from 'https://cdn.skypack.dev/dot-mustache';
</script>

README

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'
}]