npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tsxt

v0.0.4

Published

Template Engine with Types

Downloads

4

Readme

TSXT

TSXT is template engine for strongly typed JSX templates using TypeScript. The main use case is code generatation.

Installation

npm

$ npm i --save-dev tsxt

yarn

$ yarn add --dev tsxt

Also you should add tsxt to your tsconfig.json file, example configuration is:

{
  "compilerOptions": {
    "types": ["tsxt"]
  }
}

How It Works

TSXT syntax is fully compatible with JSX syntax, that means you can use eslint and prettier JSX plugins to increase the quality of your code. Also it means that you can see all type errors in template.

TSXT is a babel plugin that finds and transforms JSX nodes to string literals concatenation expressions.

For example:

export default (ctx: string) => <templ>{`Hello, ${ctx}`}</templ>;

Compiles to:

function _default(ctx) {
  return "" + ("" + `Hello, ${ctx}` + "\n");
}

You can find more examples in tests folder

You can compile your tsx templates, for example with command:

$ tsxt ./templates ./compiled-templates

Tags

TSXT provides three different tags (templ, indent, ln)

templ - main tag that tells TSXT to concatinate all children JSXExpressionContainers to one string concatination expression.

indent - simple tag that tells TSXT to increase indent for all nested JSXExpressionContainers. indent as well as templ transforms all children to one expression.

ln - another simple tag that tells TSXT to insert JSXExpressionContainer with string literal that contains \n.

Links

Medium article - https://medium.com/@iam.guid/first-typescript-jsx-based-template-engine-for-code-generation-d9be0275e6d6