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 🙏

© 2026 – Pkg Stats / Ryan Hefner

handlebars-editor-react

v0.1.4

Published

A React component for editing Handlebars templates with syntax highlighting and autocomplete

Readme

handlebars-editor-react

npm version license downloads

A React component for editing Handlebars templates with syntax highlighting and autocomplete.

Live Demo

Features

  • Syntax highlighting for all Handlebars constructs
  • Autocomplete for block helpers and variables
  • Customizable theming via CSS variables
  • TypeScript support
  • Zero dependencies (except React and Handlebars)

Installation

npm install handlebars-editor-react

Usage

import { HandlebarsEditor } from 'handlebars-editor-react';
import 'handlebars-editor-react/styles.css';

function App() {
  const [template, setTemplate] = useState('Hello {{name}}!');

  return (
    <HandlebarsEditor
      value={template}
      onChange={setTemplate}
      placeholder="Enter your template..."
    />
  );
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | value | string | required | The template content | | onChange | (value: string) => void | - | Called when content changes | | placeholder | string | "Enter template..." | Placeholder text | | readOnly | boolean | false | Disable editing | | className | string | "" | Additional CSS class | | style | CSSProperties | - | Inline styles | | theme | Partial<ThemeColors> | - | Custom colors | | customHelpers | string[] | [] | Additional helpers for autocomplete | | autocomplete | boolean | true | Enable autocomplete | | minHeight | string \| number | 100 | Minimum editor height |

Theming

Customize colors using CSS variables or the theme prop:

.hbs-editor {
  --hbs-color-variable: #3b82f6;
  --hbs-color-helper: #f59e0b;
  --hbs-color-block-keyword: #a855f7;
  --hbs-color-literal: #16a34a;
  --hbs-color-comment: #9ca3af;
}

Or via props:

<HandlebarsEditor
  value={template}
  theme={{
    variable: '#3b82f6',
    helper: '#f59e0b',
    blockKeyword: '#a855f7',
  }}
/>

Available Theme Colors

  • variable - Simple variables {{name}}
  • variablePath - Nested paths {{person.name}}
  • blockKeyword - Block keywords #if, /each, else
  • blockParam - Block parameters
  • helper - Helper names {{uppercase name}}
  • helperArg - Helper arguments
  • hashKey - Hash keys key=
  • hashValue - Hash values
  • literal - Strings, numbers, booleans
  • dataVar - Data variables @index, @key
  • subexprParen - Subexpression parentheses
  • comment - Comments
  • raw - Raw output {{{raw}}}
  • brace - Braces {{ and }}
  • text - Default text color
  • background - Editor background
  • caret - Cursor color
  • border - Border color
  • placeholder - Placeholder text color

Dark Theme

Add the hbs-theme-dark class to enable dark mode:

<HandlebarsEditor
  value={template}
  className="hbs-theme-dark"
/>

Utility Functions

The package also exports utility functions for working with Handlebars templates:

import { extract, tokenize, interpolate } from 'handlebars-editor-react';

// Extract variables from template
const result = extract('Hello {{name}}, you have {{count}} messages');
console.log(result.rootVariables); // ['name', 'count']

// Tokenize for custom rendering
const tokens = tokenize('{{#if show}}content{{/if}}');

// Interpolate template with data
const output = interpolate('Hello {{name}}!', { name: 'World' });

Supported Handlebars Syntax

  • Simple variables: {{name}}
  • Nested paths: {{person.name}}
  • Block helpers: {{#if}}, {{#each}}, {{#with}}, {{#unless}}
  • Else blocks: {{else}}
  • Helpers with arguments: {{link text url}}
  • Hash arguments: {{link "text" href=url}}
  • Subexpressions: {{helper (inner arg)}}
  • Raw output: {{{unescaped}}}
  • Comments: {{! comment }} and {{!-- block comment --}}
  • Data variables: @index, @key, @first, @last
  • Parent context: ../
  • Whitespace control: {{~trim~}}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development

# Install dependencies
pnpm install

# Run in development mode
pnpm dev

# Run tests
pnpm test

# Build
pnpm build

License

MIT - see LICENSE for details.