Skip to content

Instantly share code, notes, and snippets.

@satyajitnayk
Last active December 22, 2023 12:31
Show Gist options
  • Save satyajitnayk/657dfad8540cb0d53a1789d1349a8059 to your computer and use it in GitHub Desktop.
Save satyajitnayk/657dfad8540cb0d53a1789d1349a8059 to your computer and use it in GitHub Desktop.
Converts Handlebars Abstract Syntax Tree (AST) back to template string

Handlebars AST to Template String using hbs-ast-to-str

This Gist introduces the hbs-ast-to-str package, which provides a solution for converting Handlebars Abstract Syntax Trees (AST) into template strings.

hbs-ast-to-str

Installation

You can install the package using npm or yarn:

npm install hbs-ast-to-str

Usage

Here's a basic example of how you can use hbs-ast-to-str to convert Handlebars AST into template strings:

const {convertAstToString} = require('hbs-ast-to-str');
const ast = Handlebars.parse(template_str);
const templateString = convertAstToString(ast);
console.log(templateString);

Features

  • Converts Handlebars AST into a template string.
  • Easy to use and integrate into your project.

Documentation

For more details and advanced usage, you can check the official documentation of hbs-ast-to-str on npm.

Issues and Contributions

If you encounter any issues or want to contribute to the project, you can visit the GitHub repository and open issues or pull requests.

License

This package is open source and available under the MIT License.

Feel free to explore hbs-ast-to-str and use it to simplify your Handlebars template generation process!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment