|
| 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 | + |
| 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. |
0 commit comments