prettier-plugin-cfml
v1.0.0
Published
Prettier plugin for CFML (ColdFusion Markup Language)
Maintainers
Readme
Prettier Plugin for CFML
A production-ready Prettier plugin that formats CFML (ColdFusion Markup Language) files using an AST-based approach.
Features
- ✅ AST-based formatting - No fragile regex rules
- ✅ Mixed content support - CFML + HTML + SQL + CFScript
- ✅ Intelligent tag handling - Understands CFML tag relationships
- ✅ SQL preservation - Optional SQL formatting in
<cfquery>tags - ✅ Configurable - Extensive formatting options
- ✅ VS Code integration - Works seamlessly with Prettier extension
- ✅ Graceful error handling - Won't crash on malformed CFML
Installation
NPM Package
npm install --save-dev prettier-plugin-cfmlVS Code Extension
- Install the Prettier extension
- Install this plugin via npm in your project
- Configure VS Code settings:
{
"prettier.documentSelectors": ["**/*.cfm", "**/*.cfc", "**/*.cfml"],
"[cfml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}Configuration
Add to your .prettierrc:
{
"cfmlTabWidth": 2,
"cfmlSingleQuote": false,
"cfmlInlineThreshold": 40,
"cfmlPreserveSQL": true,
"plugins": ["prettier-plugin-cfml"]
}Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| cfmlTabWidth | integer | 2 | Spaces per indentation level |
| cfmlSingleQuote | boolean | false | Use single quotes in attributes |
| cfmlInlineThreshold | integer | 40 | Max characters for inline tags |
| cfmlPreserveSQL | boolean | true | Format SQL in <cfquery> tags |
Examples
Before
<cfquery name="getUsers" datasource="#application.dsn#">
SELECT firstName,lastName,email FROM users
WHERE active=1
</cfquery>
<cfoutput><h1>Welcome #user.name#</h1></cfoutput>After
<cfquery name="getUsers" datasource="#application.dsn#">
SELECT firstName, lastName, email
FROM users
WHERE active = 1
</cfquery>
<cfoutput>
<h1>Welcome #user.name#</h1>
</cfoutput>Supported File Types
.cfm- ColdFusion pages.cfc- ColdFusion components.cfml- General CFML files
Development
# Install dependencies
npm install
# Build
npm run build
# Test
npm test
# Development mode
npm run devLicense
MIT License - feel free to use in any project!
