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

@domchristie/composite

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domchristie/composite

A hybrid client-side/server-side approach to generating dynamic HTML.

  • 0.3.0
  • npm
  • Socket score

Version published
Weekly downloads
46
increased by228.57%
Maintainers
1
Weekly downloads
 
Created
Source

🦷 Composite

A hybrid client-side/server-side approach to generating dynamic HTML.

Compose your HTML in <template> elements. Use placeholders (${…}) to mark dynamic content. Call fill to generate a new HTML string which interpolates the template's content with the given properties.

Usage

npm install @domchristie/composite
/* rendered somewhere in the DOM */
<template id="hello">
  <h1>${greeting}, ${name}!</h1>
</template>
import { fill } from '@domchristie/composite'
const Hello = document.getElementById('hello')
fill(Hello, { greeting: 'Hello', name: 'World' }) // '<h1>Hello, World!</h1>'

Escaping HTML and Unescaping with raw

Template placeholders are automatically HTML-escaped to prevent cross-site scripting (XSS) attacks. To output content without escaping, use raw:

<template id="hello">
  <h1>${raw(greeting)}, ${name}!</h1>
</template>

License

Copyright © 2024+ Dom Christie and released under the MIT license.

Keywords

FAQs

Package last updated on 13 Jun 2024

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