# @glimmerx/prettier-plugin-component-templates 中文文档

规范地址：https://npmcn.com/package/%40glimmerx/prettier-plugin-component-templates/

版本：0\.6\.8
npm 元数据更新时间：2026-07-21T17:15:06.608Z
中文译文更新时间：2026-11-16T16:02:53.992Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40glimmerx/prettier-plugin-component-templates
原文对照：https://npmcn.com/package/%40glimmerx/prettier-plugin-component-templates/?lang=original
项目主页：https://github.com/glimmerjs/glimmer-experimental#readme
源码仓库：https://github.com/glimmerjs/glimmer-experimental

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：7.3 kB，5 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：0 个
- 首次发布：2021-07-15T21:19:10.979Z
- 最新版本发布：2022-09-06T16:09:13.931Z
- 近 30 天下载量：3684（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

闪光组件模板的更美格式

## 安装

```sh
npm install @glimmerx/prettier-plugin-component-templates
```

也可以使用：`pnpm add @glimmerx/prettier-plugin-component-templates`、`yarn add @glimmerx/prettier-plugin-component-templates`、`bun add @glimmerx/prettier-plugin-component-templates`

## README

# @ glimmerx/ pretier- plugin- 组件- templades

## 背景情况

[高级](https://prettier.io/docs/en/index.html) 是一个有观点的代码。 在预告片 `>2.0` 有支持 `*.hbs` 闪光文件,但不支持实验语法 `glimmerx` 组件被写入.

## 导言

此插件将内部打印机扩展为在闪光模板中添加嵌入式语法 `hbs` 标记图示 .

## 安装和使用

```bash
yarn add -D @glimmerx/prettier-plugin-component-templates
```

一旦添加更美,将发现并使用插件格式化任何 `hbs` 标记模板表达式 .

### 选项

在您的更漂亮的配置选项中( 例如 ) . `.prettierrc`, (中文(简体) ), `prettier.config.js`页:1

`.prettierrc`

```json
{
  "hbsSingleQuote": true
}
```

默认为 `false` 对嵌入于 hbs 中的所有属性强制双引号 。 何时 `true` 将所有引用重写为单引号.

## 发展

生成一个测试案例, 添加到测试文件中,

添加 `PRETTIER_DEBUG=true` 在运行插件时向环境移动,以获取错误的完整堆栈痕迹.

### 调试

#### 调试

```
PRETTIER_DEBUG=true node --inspect-brk  node_modules/.bin/prettier --config=./test/fixtures/basic/config.js ./test/fixtures/basic/code.js
```

### 生成快照

```
node node_modules/.bin/prettier --ignore-path --config=./test/fixtures/simple-formatted/config.js ./test/fixtures/simple-formatted/code.js > ./test/fixtures/simple-formatted/output.js
```

### 测试

#### 运行所有测试

```
yarn test
```

## 开始

-   [ ] 添加对支持 `<template>` 标记语义.

## 常见问题

### @glimmerx/prettier-plugin-component-templates 是什么？

闪光组件模板的更美格式

### 如何安装 @glimmerx/prettier-plugin-component-templates？

在项目目录运行 npm install @glimmerx/prettier-plugin-component-templates，或使用 pnpm add / yarn add / bun add。

### @glimmerx/prettier-plugin-component-templates 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/glimmerx\_\_prettier-plugin-component-templates 是否存在。

### @glimmerx/prettier-plugin-component-templates 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @glimmerx/prettier-plugin-component-templates 可以商用吗？

@glimmerx/prettier-plugin-component-templates 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @glimmerx/prettier-plugin-component-templates 的下载量有多少？

根据 npm 官方下载统计，@glimmerx/prettier-plugin-component-templates 在 2026/10/17 – 2026/11/15 这 30 天内被下载 3,684 次，日均约 123 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @glimmerx/prettier-plugin-component-templates 还在维护吗？

最新版本 0\.6\.8 发布于 2022/09/07（4 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2021/07/16。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

