How to use the lit-html/directives/unsafe-html.js.unsafeHTML function in lit-html

To help you get started, we’ve selected a few lit-html 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 CitizensFoundation / open-active-voting / public / src / components / oav-select-voting-area.js View on Github external
renderText() {
    if (this.hasLoadedCss) {
      return html`${unsafeHTML(this.setupHTMLText(this.getText()))}`
    } else {
      return html``;
    }
  }
github pattern-lab / patternlab-node / packages / uikit-workshop / src / scripts / components / panels-viewer.js View on Github external
const codeTemplate = (code, language) =>
                html`
                  <pre class="language-markup"><code class="language-${language}" id="pl-code-fill-${language}">${unsafeHTML(
                    code
                  )}</code></pre>
                `;
github ebi-webcomponents / nightingale / packages / protvista-datatable / src / protvista-datatable.js View on Github external
const hasChildData = this.hasChildData(childRowItems, row);
              return html`
                
                  ${hasChildData
                    ? html`
                        
                          ${this.visibleChildren.includes(row.id)
                            ? unsafeHTML(MinusSVG)
                            : unsafeHTML(PlusSVG)}
                        
                      `
                    : html`
                        
                      `}
                  ${Object.keys(this.columns)
                    .filter(column =&gt; !this.columns[column].child)
                    .map(
                      column =&gt;
                        html`
                          
                            ${this.columns[column].resolver(row)}
                          
                        `
                    )}
github web-padawan / api-viewer-element / src / lib / markdown.ts View on Github external
export const parse = (markdown?: string): TemplateResult => {
  if (!markdown) {
    return html`
      ${nothing}
    `;
  }

  return html`
    ${unsafeHTML(DOMPurify.sanitize(marked(markdown)))}
  `;
};
github ink-components / ink-components / src / InkCode.js View on Github external
}
              button{
                position: absolute;
                top: 0;
                right: 0;
                text-transform: uppercase;
                border: none;
                cursor: pointer;
                background: #e0e0e0;
                outline: none;
              }
            
            <hr>
            <div id="code-wrapper">
              <button title="copy to clipboard">${ this._copyText}</button>
              <pre><code class="hljs ${ this.language }">${ unsafeHTML(codeDom.innerHTML) }</code></pre>
            </div>
            <hr>
            
        `;
    }
}
github CitizensFoundation / open-active-voting / public / src / components / oav-select-voting-area.js View on Github external
render() {
    if (this.hasLoadedCss) {
      return html`${this.wide ?
        html`${unsafeHTML(this.setupHTMLText(this.configFromServer.client_config.selectVotingAreaDesktopHTML))}` :
        html`${unsafeHTML(this.setupHTMLText(this.configFromServer.client_config.selectVotingAreaMobileHTML))}`}`;
    } else {
      return html``;
    }
  }
github PolymerLabs / books / src / components / book-item.js View on Github external
render() {
    const { item } = this;
    const info = item &amp;&amp; item.volumeInfo;
    const id = item ? item.id : '';
    const title = info ? info.title : '';
    const author = info ? info.authors &amp;&amp; info.authors.join(', ') : '';
    const thumbnail = info ? info.imageLinks.thumbnail.replace('http', 'https').replace('&amp;edge=curl', '') : null;
    const date = info ? new Date(info.publishedDate).getFullYear() : '';
    const rating = info &amp;&amp; info.averageRating;
    const desc = info ? unsafeHTML(info.description || info.subtitle || '<i>No descriptions.</i>') : '';

    return html`
      <a href="/detail/${id}">
        <div class="info">
          
          <div class="info-section">
            <div class="title-container">
              <h2 class="title">${title}</h2>
            </div>
            <div class="author info-item">${author} - ${date}</div>
            <div class="info-item">
              
            </div>
          </div>
        </div>
        <div class="desc">${desc}</div></a>
github ink-components / ink-components / src / InkEquation.js View on Github external
var element = document.createElement('div');

        katex.render(
            this.aligned ? `\\begin{aligned}${ this.math }\\end{aligned}` : this.math,
            element,
            {
                displayMode: !this.inline,
                macros: {
                    "\\boldsymbol": "\\mathbf"
                }
            }
        );

        return html`
            ${ katexCSS }
            ${ unsafeHTML(element.innerHTML) }
        `;
    }
}
github PolymerLabs / books / src / components / book-detail.js View on Github external
<button class="fav-button">
                ${isFavorite ? favoriteIcon : favoriteBorderIcon} ${isFavorite ? 'Added to Favorites' : 'Add to Favorites'}
              </button>
            
            <div class="preview-btn-container">
              <a class="book-button" href="/viewer/${_item.id}">PREVIEW</a>
            </div>
          
        
        <div class="rating-container">
          
          <span>(${ratingsCount || 0} ${ratingsCount == 1 ? 'review' : 'reviews'})</span>
        </div>
        <div class="desc">
          <h3>Description</h3>
          ${unsafeHTML(info.description || info.subtitle || 'None')}
        </div>
        <div class="desc">
          <h3>Categories</h3>
          <ul>
            ${repeat(categories, (item) =&gt; html`
              <li>${item}</li>
            `)}
          </ul>
        </div>
        <div class="desc">
          <h3>ISBN</h3>
          <ul>
            ${repeat(identifiers, (item) =&gt; html`
              <li>${item.type}: ${item.identifier}</li>
            `)}
          </ul></div>