vqua-interpolate

1.0.32 • Public • Published

← 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'
  //       ],
  //     },
  //     '!',
  //   ]
  // }

/vqua-interpolate/

    Package Sidebar

    Install

    npm i vqua-interpolate

    Weekly Downloads

    17

    Version

    1.0.32

    License

    ISC

    Unpacked Size

    7.92 kB

    Total Files

    11

    Last publish

    Collaborators

    • sterjakov