Skip to content

Commit d7669c7

Browse files
committed
docs: fix React snippet example and clarify snippet limitations
The previous JSX snippet example with plain JavaScript code doesn't work because Emmet snippets must use Emmet abbreviation syntax, not arbitrary text. Changes: - Replaced React component example with working JSX snippets - Added note explaining snippet syntax requirements - Clarified that plain text/code will be treated as tag names
1 parent 786b099 commit d7669c7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ emmet expand "hero" --syntax html
230230
emmet expand "fx" --syntax css
231231
```
232232

233+
**Important:** Snippets must be valid Emmet abbreviation syntax (tags, classes, IDs, nesting operators like `>`, `+`, `^`, etc.). Plain text or code won't work - it will be treated as a tag name.
234+
233235
### syntaxProfiles.json
234236

235237
Customize output formatting per syntax:
@@ -343,24 +345,32 @@ emmet expand "div.block>div.block__element" --syntax html --filter "bem,c"
343345

344346
## Example Workflows
345347

346-
### React Component Generation
348+
### React Component Snippets
347349

348350
Create `.emmet/snippets.json`:
349351
```json
350352
{
351353
"jsx": {
352354
"snippets": {
353-
"rfc": "import React from 'react';\n\nconst Component = () => {\n return <div></div>;\n};\n\nexport default Component;"
355+
"card": "div.card>div.card-header>h3{Title}^div.card-body>p{Content}",
356+
"modal": "div.modal>div.modal-content>div.modal-header>h2{Modal Title}^div.modal-body>p{Modal content}^div.modal-footer>button{Close}",
357+
"form": "form>div.form-group>label{Name}+input[type=text name=username]^button[type=submit]{Submit}"
354358
}
355359
}
356360
}
357361
```
358362

359363
Usage:
360364
```bash
361-
emmet expand "rfc" --syntax jsx > Component.jsx
365+
emmet expand "card" --syntax jsx --no-tab-stops
366+
# Output: <div className="card">...</div>
367+
368+
emmet expand "form" --syntax jsx --no-tab-stops
369+
# Generates complete form structure with JSX syntax
362370
```
363371

372+
**Note:** Emmet snippets must use Emmet abbreviation syntax (tags, classes, nesting). They cannot contain arbitrary JavaScript code.
373+
364374
### CSS Utility Classes
365375

366376
Create `.emmet/snippets.json`:

0 commit comments

Comments
 (0)