How to use the @bbob/plugin-helper.attrsToString function in @bbob/plugin-helper

To help you get started, we’ve selected a few @bbob/plugin-helper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JiLiZART / bbob / packages / bbob-html / src / index.js View on Github external
const renderNode = (node, { stripTags = false }) => {
  if (!node) return '';
  const type = typeof node;

  if (type === 'string' || type === 'number') {
    return node;
  }

  if (type === 'object') {
    if (stripTags === true) {
      // eslint-disable-next-line no-use-before-define
      return renderNodes(node.content, { stripTags });
    }

    if (node.content === null) {
      return [START_TAG, node.tag, attrsToString(node.attrs), SELFCLOSE_END_TAG].join('');
    }

    // eslint-disable-next-line no-use-before-define
    return [START_TAG, node.tag, attrsToString(node.attrs), END_TAG, renderNodes(node.content), CLOSE_START_TAG, node.tag, END_TAG].join('');
  }

  if (Array.isArray(node)) {
    // eslint-disable-next-line no-use-before-define
    return renderNodes(node, { stripTags });
  }

  return '';
};