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

jeasx-html

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jeasx-html

JSX-based html templating engine for Node environments.

  • 0.0.6
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

JSX HTML Template Engine

A JSX based html templating engine for Node environments.

Getting started

Installation

npm i jeasx-html

or

yarn add jeasx-html

Building

To use the jeasx-html you will have to set up your transpiler to use this package for transforming the JSX syntax, if you use typescript for transpiling all you have to do is set these options in the tsconfig:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "jeasx-html"
  }
}

Using

In case you use the templates in a server app in a Node environment you might want to include some data from the database in the html you serve to the client. To make it easier to fetch what's needed and marry it with the templates you can make your components asynchronous and send async requests from within them.

import { renderToHtml } from "jeasx-html";

function Header({ label }) {
  return <h1>{label}</h1>;
}

async function ToDoList() {
  const { todos } = await (await fetch("https://dummyjson.com/todos")).json();

  return (
    <table>
      <thead>
        <tr>
          <th>ID</th>
          <th>Label</th>
          <th>Is Done?</th>
        </tr>
      </thead>
      <tbody>
        {todos.map(({ id, todo, completed }) => (
          <tr>
            <td>{id}</td>
            <td>{todo}</td>
            <td>{completed ? "yes" : "no"}</td>
          </tr>
        ))}
      </tbody>
    </table>
  );
}

function App() {
  return (
    <html>
      <head>
        <meta charset="utf-8" />
      </head>
      <body>
        <Header label="ToDos" />
        <ToDoList />
      </body>
    </html>
  );
}

const html = await renderToHtml(<App />);

Keywords

FAQs

Package last updated on 09 Dec 2023

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