Skip to content

Commit 0b45ac9

Browse files
Update docs to: Implement Templates system (#117)
1 parent 6969552 commit 0b45ac9

4 files changed

Lines changed: 97 additions & 3 deletions

File tree

93 KB
Loading

docs/menus.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ file and then continue editing.
2222
Opens another window of the editor. Due to the lack of support for multi-file editing (currently),
2323
this is a good way to work with multiple files.
2424

25+
### New With Template
26+
It lists all templates, clicking on any template will create new file with that template.
27+
2528
### Open
2629
Creates a pop-up to select and open an existing file.
2730

@@ -269,6 +272,15 @@ apply last line indention level for new line.
269272
### Remove All Indents
270273
Removes all indention and white spaces in both side of all lines.
271274

275+
### Continue Placeholder Completion
276+
Returns you to Placeholder completion mode (when current file has any placeholder).
277+
278+
### Save As Template
279+
Saves current file as a template with given name.
280+
281+
### Templates
282+
Shows *Template Manager* window to view, edit, and remove templates.
283+
272284
## View
273285
This menu includes options and actions related to editor layout and visible items.
274286

@@ -390,16 +402,13 @@ Opens about dialog.
390402
There are some options that are always disabled in menus and are not yet available, these are listed
391403
below:
392404

393-
- File > New With Template
394405
- Go To > Code Regions
395406
- Go To > Insert Navigation Mark
396407
- Go To > Navigation Marks
397408
- Go To > Table Of Contents
398409
- Go To > Bookmarks
399410
- Go To > Toggle Bookmark
400411
- Go To > Remove All Bookmarks
401-
- Format > Save As Template
402-
- Format > Templates
403412
- Tools > Security
404413
- Tools > Counter
405414
- Tools > Translation

docs/templates.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Templates in Text Forge
2+
3+
You can use templates to save time and reuse frequently used patterns. This page explains how to
4+
create and use templates.
5+
6+
## Create Your First Template
7+
8+
Let's create your first template. In this example, we'll write a template for recording daily reports.
9+
To start, create a new file using the New option.
10+
11+
!!! Tip
12+
13+
You can select **File > New** from the menu, use the shortcut `Ctrl + N`, or execute this command
14+
from the command palette.
15+
16+
You can write your template like any other file. Use {{{}}} for placeholders to enable quick completion
17+
features when using the template. There are also several predefined internal placeholders that you can use:
18+
19+
- `{{{!file_name}}}` - The name of the file created from the template
20+
- `{{{!file_path}}}` - The path of the file created from the template
21+
- `{{{!time}}}` - The creation time of the instance in HH:MM:SS format
22+
- `{{{!date}}}` - The creation date of the instance in YYYY-MM-DD format
23+
- `{{{!datetime}}}` - The creation date and time of the instance in YYYY-MM-DD HH:MM:SS format
24+
25+
For example, we create this template:
26+
27+
```markdown
28+
# Daily Report - {{{!date}}}
29+
30+
## Project: {{{project}}}
31+
## Author: {{{author}}}
32+
33+
### Completed Tasks
34+
- {{{task_1}}}
35+
- {{{task_2}}}
36+
- {{{task_3}}}
37+
38+
### Key Notes
39+
- {{{note_1}}}
40+
- {{{note_2}}}
41+
42+
### Plan for Tomorrow
43+
- {{{next_step_1}}}
44+
- {{{next_step_2}}}
45+
46+
---
47+
48+
🕐 Logged at: {{{!time}}}
49+
```
50+
51+
Our template is ready. To save it, select **Save As Template** from the **Format** menu, confirm the pop-up,
52+
and enter a name for your template. Once you save it, you can use it as a template from now on.
53+
54+
## Using a Template
55+
56+
Templates help you create new files quickly, so we've placed them alongside other new file creation
57+
options. You can see the available templates and select one from **File > New With Template**.
58+
59+
After selecting a template, the new file is created with the template, and you enter Placeholder
60+
replacement mode:
61+
62+
![image.png](https://text-forge.github.io/docs/img/placeholder-replacement.png)
63+
64+
On the left side of the replace panel, the Auto Insert option is displayed, indicating that `{{{!date}}}`
65+
is a predefined placeholder. If you hover your mouse over it, you can see more information. We can
66+
use this option to replace the placeholder with the current date, or we can enter our desired value.
67+
In any case, after pressing the `Enter` key, the replacement is done, and the next placeholder is
68+
selected. After completing this placeholder, the `{{{project}}}` placeholder is selected, and since
69+
it is not a predefined placeholder, the Auto Insert option is not available.
70+
71+
There are other options in this panel:
72+
73+
- Next: Takes you to the next placeholder
74+
- Previous: Takes you to the previous placeholder
75+
- Close: Exits Placeholder replacement mode
76+
77+
You can continue completing and then save the file, but you can postpone completion. To do this, use
78+
the `Escape` key or the Close option. You can return to completion mode at any time using the **Format > Continue Placeholder Completion** option.
79+
80+
## Editing and Deleting Templates
81+
82+
So far, we have examined the methods of creating and using templates. Another feature is the Template
83+
Manager, which allows you to easily edit or delete templates. To open it, you can use the **Format > Templates...**
84+
option. In the window that opens, you can select templates, preview them, and edit or delete them.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ nav:
2525
- Introduction: introduction.md
2626
- Setup: setup.md
2727
- Guides:
28+
- Templates: templates.md
2829
- Menus: menus.md
2930
- Themes: themes.md
3031
- Architecture:

0 commit comments

Comments
 (0)