New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@popeindustries/lit-html

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@popeindustries/lit-html

Seamlessly render lit-html templates on the server and in the browser

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-0.67%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Version

@popeindustries/lit-html

Seamlessly render the same lit-html templates on the server and in the browser. This project is a wrapper around lit-html and @popeindustries/lit-html-server to handle import aliasing.

Until there is a standard technique for establishing environment specific import aliases, this library uses the unoffical package.json#browser field, currently supported by all major bundler tools.

Usage

Install with npm/yarn:

$ npm install --save @popeindustries/lit-html @popeindustries/lit-html-server lit-html

@popeindustries/lit-html-server and lit-html are peer dependencies and must be installed separately

...write your lit-html template:

import { html } from '@popeindustries/lit-html';
import { classMap } from '@popeindustries/lit-html/directives/class-map.js';

export function Body(data) {
  return html`
    <h1>${data.title}</h1>
    <p class="${classMap({ negative: data.invertedText })}">${data.text}</p>
  `;
}

...import the template file on the client:

import { Body } from './body.js';
import { render } from '@popeindustries/lit-html';

render(Body({ title: 'hi!', text: 'some text', invertedText: false }), document.body);

...and import the same template file on the server:

import { Body } from './body.js';
import { html, renderToStream } from '@popeindustries/lit-html';
import http from 'http';

http.createServer((request, response) => {
  const data = { title: 'hi!', text: 'some text', invertedText: false };

  response.writeHead(200);
  renderToStream(html`
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
      </head>
      <body>
        ${Body(data)}
      </body>
    </html>
  `).pipe(response);
});

Keywords

FAQs

Package last updated on 22 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc