Skip to content

Commit c9ea46e

Browse files
committed
chore: update docs
1 parent c38eebc commit c9ea46e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/guide/helper-functions.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,45 @@ Hello, World!
3737
─────────────
3838
```
3939

40+
### `format_text`
41+
42+
Thu helper is designed to prepare plain or structured text for HTML or Markdown-like rendering. It does the following:
43+
44+
- Replaces line breaks (`\n`) in the input text with a custom line break string (like `<br/>` or an actual newline).
45+
46+
- Wraps inline code snippets—identified by delimiter pairs like <code>\`</code> or `'` — in `<code>` tags for HTML formatting (e.g., turning 'param' into `<code>param</code>`).
47+
48+
This helper is especially useful for formatting capability descriptions in web documentation, markdown previews, or any UI where readable line breaks and inline code styling are needed.
49+
50+
The `code_wrap_chars` parameter (last parameter of the helper function) defines pairs of characters that will wrap inline code blocks and get converted to <code>...</code> in the output.
51+
52+
You must pass a string made up of an even number of characters, where each two characters form one pair:
53+
54+
The first character is the opening delimiter
55+
The last character is the closing delimiter
56+
57+
| Input | Effect |
58+
| -------- | -------------------------------------- |
59+
| `"[]"` | Matches `[code]``<code>code</code>` |
60+
| `"''"` | Matches `'code'``<code>code</code>` |
61+
| `"['']"` | Matches both `[code]` and `'code'` |
62+
63+
Example:
64+
65+
```hbs
66+
{{format_text "Each entry includes 'name', `type` , and 'children' for directories." "<br>" "'``'" }}
67+
```
68+
69+
Output text:
70+
71+
```md
72+
Each entry includes <code>name</code>, <code>type</code> , and <code>children</code> for directories.
73+
```
74+
75+
Rendered Output:
76+
77+
Each entry includes <code>name</code>, <code>type</code> , and <code>children</code> for directories.
78+
4079
### `capability`
4180

4281
This helper formats a capability with an optional count and a boolean indicator based on whether the capability is supported.

0 commit comments

Comments
 (0)