Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
lib
spec/support
package.json
readme.md

readme.md

← back

Vqua interpolate

Replace variables from vqua text nodes.

Example

  const vquaInterpolate = require('vqua-interpolate')

  const nodes = [
    {
      type: TAG_TYPE,
      tag: 'div',
      props: {},
      childs: [
        'Hello {{ name }}, from {{ author }}!',
      ]
    }
  ]

  const interpolatedNodes =
    vquaInterpolate(nodes, {
      name: 'stranger',
      author: {
        type: TAG_TYPE,
        tag: 'span',
        props: {},
        childs: [
          'sun'
        ],
      }
    })

  // interpolatedNodes =>
  // 
  // {
  //   type: TAG_TYPE,
  //   tag: 'div',
  //   props: {},
  //   childs: [
  //     'Hello stranger, from ',
  //     {
  //       type: TAG_TYPE,
  //       tag: 'span',
  //       props: {},
  //       childs: [
  //         'sun'
  //       ],
  //     },
  //     '!',
  //   ]
  // }