https://github.com/hubspot/prettier-plugin-hubl
https://github.com/hubspot/prettier-plugin-hubl
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hubspot/prettier-plugin-hubl
- Owner: HubSpot
- License: other
- Created: 2022-04-06T20:34:18.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-05-23T02:23:00.000Z (about 1 year ago)
- Last Synced: 2025-10-10T09:34:13.316Z (9 months ago)
- Language: HTML
- Size: 865 KB
- Stars: 25
- Watchers: 122
- Forks: 5
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prettier-plugin-hubl
A Prettier plugin that formats HubL templates for use with the HubSpot CMS
## Plugin status: Beta
This plugin is currently in active development. Bug reports and questions [are welcomed](https://github.com/HubSpot/prettier-plugin-hubl/issues).
## Philosophy
In keeping with Prettier’s philosophy, this plugin is relatively opinionated and sometimes Prettier will prefer one syntax over another. For example:
- `{{ foo is string_containing “bar” }}` will become `{{ foo is string_containing(“bar”) }}`
- `a && b` will `become a and b`
- `c || d` will become `c or d`
If you have a particular code-style opinion that you feel strongly about, feel free to [open an issue](https://github.com/HubSpot/prettier-plugin-hubl/issues/new) for review.
## Installing
You can install this plugin directly from NPM by running:
```bash
npm i @hubspot/prettier-plugin-hubl -D
```
If you haven't already installed [prettier](https://prettier.io) you'll want to do that as well:
```bash
npm i prettier -D
```
## Setup
**Note**: Starting with Prettier 3.x, plugins must be explicitly listed in your Prettier configuration. Auto-discovery has been removed.
If you don't already have a prettier config file, create one:
```json
# .prettierrc.json
{
"plugins": ["@hubspot/prettier-plugin-hubl"],
"overrides": [
{
"files": "*.html",
"options": {
"parser": "hubl"
}
}
]
}
```
Run prettier
```bash
npx prettier --write '**/*.html'
```
## Troubleshooting Errors
Check under “Known Issues” to see if your error has been reported already. If not, feel free to [open up a new issue](https://github.com/HubSpot/prettier-plugin-hubl/issues/new). You can also review the expected formatting of different elements [here](./TYPE_DOCS.md).
## Community
You can stay up to date with HubSpot CMS Boilerplate updates and discussions in the #hs-cms-boilerplate channel in the HubSpot Developer Slack.