How to use the he.escape function in he

To help you get started, we’ve selected a few he 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 voltraco / mineral / compilers / html.js View on Github external
// if this attribute is a boolean, make its value its key
        if (typeof value === 'boolean') {
          return [key, '=', `"${key}"`].join('')
        }

        if (value) {
          // all values are expressions
          value = common.scopedExpression(data, locationData, value)

          // a class should not be empty
          if (key === 'class' && !value) return ''

          // data-* attributes should be escaped
          if (key.indexOf('data-') === 0) {
            if (typeof value !== 'string' && typeof value !== 'number') {
              value = he.escape(JSON.stringify(value) + '')
            } else {
              value = '"' + value + '"'
            }
          } else {
            value = JSON.stringify(value)
          }
        }
        return [key, '=', value].join('')
      })
      attrs = attrs.filter(a => !!a)
github propelml / propel / website / nb.tsx View on Github external
function createIframe(rpcChannelId): HTMLIFrameElement {
  const base = new URL("/sandbox", window.document.baseURI).href;
  const html = `
    
      
        
        
        
        
      
      
      
    `;

  const iframe = document.createElement("iframe");
  iframe.setAttribute("sandbox", "allow-scripts");
  iframe.setAttribute("srcdoc", `${html}`);
  // Edge doesn't support "srcdoc", it'll use a data url instead.
  iframe.setAttribute("src", `data:text/html,${html}`);
  iframe.style.display = "none";
  document.body.appendChild(iframe);

  return iframe;
github odoe / presentations / 2016-European-DevSummit / 2016-berlin-frameworks / demos / vuetest / node_modules / vue / src / server / render.js View on Github external
}
        if (getKey && !name) {
          warnOnce(
            `[vue-server-renderer] Components that implement "serverCacheKey" ` +
            `must also define a unique "name" option.`
          )
        }
        renderComponent(node, write, next, isRoot)
      }
    } else {
      if (node.tag) {
        renderElement(node, write, next, isRoot)
      } else if (node.isComment) {
        write(``, next)
      } else {
        write(node.raw ? node.text : escape(String(node.text)), next)
      }
    }
  }
github matrix-org / matrix-bifrost / src / xmppjs / XHTMLIM.ts View on Github external
ontext: (text) => {
                xhtml += `${he.escape(text)}`;
            },
            onclosetag: (tagname) => {
github nylas-mail-lives / nylas-mail / packages / isomorphic-core / src / message-utils.es6 View on Github external
function htmlifyPlaintext(text) {
  const escapedText = he.escape(text);
  return `<pre class="nylas-plaintext">${escapedText}</pre>`;
}
github kaola-fed / megalo / src / server / render.js View on Github external
}
      if (getKey &amp;&amp; !name) {
        warnOnce(
          `[vue-server-renderer] Components that implement "serverCacheKey" ` +
          `must also define a unique "name" option.`
        )
      }
      renderComponent(node, isRoot, context)
    }
  } else {
    if (node.tag) {
      renderElement(node, isRoot, context)
    } else if (node.isComment) {
      write(``, next)
    } else {
      write(node.raw ? node.text : escape(String(node.text)), next)
    }
  }
}
github GeekyAnts / vue-native-core / src / server / render.js View on Github external
function renderNode (node, isRoot, context) {
  if (isDef(node.componentOptions)) {
    renderComponent(node, isRoot, context)
  } else {
    if (isDef(node.tag)) {
      renderElement(node, isRoot, context)
    } else if (isTrue(node.isComment)) {
      context.write(
        ``,
        context.next
      )
    } else {
      context.write(
        node.raw ? node.text : escape(String(node.text)),
        context.next
      )
    }
  }
}
github GeekyAnts / vue-native-core / src / platforms / web / server / modules / attrs.js View on Github external
export function renderAttr (key: string, value: string): string {
  if (isBooleanAttr(key)) {
    if (!isFalsyAttrValue(value)) {
      return ` ${key}="${key}"`
    }
  } else if (isEnumeratedAttr(key)) {
    return ` ${key}="${isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'}"`
  } else if (!isFalsyAttrValue(value)) {
    return ` ${key}="${typeof value === 'string' ? escape(value) : value}"`
  }
  return ''
}

he

A robust HTML entities encoder/decoder with full Unicode support.

MIT
Latest version published 6 years ago

Package Health Score

70 / 100
Full package analysis