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

babel-plugin-transform-diffhtml

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-diffhtml

Compiles tagged templates into createTree calls

  • 1.0.0-beta.29
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

<±/> babel-plugin-transform-diffhtml

Babel transform for pre-parsing and compiling diffHTML template functions to createTree calls which reduces runtime HTML parse cost.

Latest version: 1.0.0-beta.29

Refer to the website https://diffhtml.org/tools.html#babel-transform for documentation.

Installation

Using npm:

npm install --save-dev babel-plugin-transform-diffhtml

or using yarn:

yarn add babel-plugin-transform-diffhtml --dev

Simple example

.babelrc:

{
  "plugins": [
    ["babel-plugin-transform-diffhtml", { "createTree": "_diffhtml.html" }]
  ]
}

input.js:

import { innerHTML, html } from 'diffhtml';

function main() {
  innerHTML(document.body, html`
    <div><h1>Hello world</h1></div>
  `);
}

main();

babel input.js:

var _vtree = _diffhtml.html("#text", "Hello world");

import { innerHTML, html } from 'diffhtml';

function main() {
  innerHTML(document.body, _diffhtml.html("div", {}, [_diffhtml.html("h1", {}, [_diffhtml.html("#text", "Hello world")])]));
}

main();

You may need to tweak the "createTree" option to get the appropriate output in the source to match how diffHTML is embedded and what build system you used.

FAQs

Package last updated on 30 Oct 2022

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