Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vdo

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vdo

Minimal JSX compatible html focused templating engine.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

VDO

The lightweight JSX compatible templating engine.

Why

JSX is powerful compared to other templating engines but it has some warts. It has some abstractions that simply don't make sense for creating html (ala className). "VDO" provides a JSX interface that is specifically designed for rendering html, not DOM.

Features

  • Minimal API.
  • ~1kb min/gzip.
  • No extra "data-react-id".
  • No random span's.
  • Allows any custom attribute (react only allows data-).
  • Render nested arrays.
  • Optimized for rendering html.
  • JSX compatible.

Installation

Npm
npm install vdo
Bower
bower install vdo

Example

/** @jsx vdo */
const vdo = require('vdo');

function MyPartial (attrs, children) {
    return <span class="custom" data-value={attrs.value}/>;
}

const html = (
    <div class="root">
        <MyPartial value="1"/>
    </div>
);

document.body.innerHTML = html;

API

  • isElement(element) : Tests if given element is a vdo virtual element.
vdo.isElement(<div/>); // true
  • with(context, renderer) : Gives all components inside a render function some external context.
// renderer must be a function that returns a virtual node.
function MyComponent (props, children, context) {
    return (
        <div>External data: { context }</div>
    );
}

String(vdo.with(1, ()=> <MyComponent/>));
//-> "<div>External Data: 1</div>"
  • createElement(type, props, children...) : Create a virtual node/component.
// Automatically called when using JSX.
let vNode = vdo.createElement("div", { editable: true }, "Hello World");
// Or call vdo directly
let vNode = vdo("div", { editable: true }, "Hello World");

// Render to string on the server.
vNode.toString(); // '<div editable="true">Hello World</div>';

/**
 * @params type can also be a function (shown in example above).
 */

Contributions

  • Use gulp to run tests.

Please feel free to create a PR!

Keywords

FAQs

Package last updated on 11 Mar 2016

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