Skip to content

Commit 96884bf

Browse files
committed
chore: improve docs
1 parent 1cd7e0d commit 96884bf

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

blog/2024-10-24-textwire-v2.1.0-release-notes/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Regarding improvements, I placed a strong emphasis on proper error handling. I c
5050

5151
- 🐛 **Fixed Bug with Prefix Expression Precedence**: Resolved an issue where prefix expressions like `{{ -1.abs() }}` were not being processed correctly. Previously, the parser evaluated the expression as `{{ (-(1.abs())) }}`, resulting in an incorrect output of `-1`. Now, the parser correctly handles the precedence, evaluating it as `{{ ((-1).abs()) }}`.
5252
- 🧑‍💻 **Enhanced Error Handling for Built-in Functions:** Improved error messages when an incorrect argument type is passed to a built-in function. Users will now receive clear error messages indicating the type mismatch.
53-
- 🧑‍💻 **Enhanced Error Handling for Custom Functions:** If a function is called on a type where it doesn’t exist, Textwire now provides a detailed error message specifying that the function is undefined for that type. For example, an error message might read: `[Textwire ERROR in /var/www/html/templates/home.tw.html:3]: function 'some' doesn't exist for type 'STRING'`.
53+
- 🧑‍💻 **Enhanced Error Handling for Custom Functions:** If a function is called on a type where it doesn’t exist, Textwire now provides a detailed error message specifying that the function is undefined for that type. For example, an error message might read: `[Textwire ERROR in /var/www/html/templates/home.tw:3]: function 'some' doesn't exist for type 'STRING'`.
5454
- 🧑‍💻 **Enhanced Error Handling for Division by Zero:** Improved error messages for division-by-zero cases, replacing previous vague messages with more meaningful ones.
5555
- 🧑‍💻 New error page while rendering a template. Instead of black screen we now get a simple error page with `Sorry! We’re having some trouble right now. Please check back shortly`. You can find more information [here](/docs/v2/guides/error-handling)
5656

@@ -65,4 +65,4 @@ Some very small changes were made to the Textwire that don't effect any function
6565
Version `v2.1.0` of Textwire brings a host of new built-in functions, improved error handling, and other enhancements. I hope you enjoy using Textwire as much as I enjoy developing it. If you have any questions or feedback, please don't hesitate to reach out to me. I'm always happy to help. Thank you for your continued support and feedback. Stay tuned for more updates and improvements in the future. Happy coding! 🚀
6666

6767
## What's next?
68-
In the next version, I'll focus on further improvements to the language, including new built-in functions, better error handling, more tests, and the ability to define a custom error page for templates. Stay tuned for more updates and improvements in the future. Happy coding! 🚀
68+
In the next version, I'll focus on further improvements to the language, including new built-in functions, better error handling, more tests, and the ability to define a custom error page for templates. Stay tuned for more updates and improvements in the future. Happy coding! 🚀

versioned_docs/version-v2/guides/template-usage.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ import (
1616
"net/http"
1717

1818
"github.com/textwire/textwire/v2"
19+
"github.com/textwire/textwire/v2/config"
1920
)
2021

2122
var tpl *textwire.Template
2223

2324
func main() {
2425
var err error
2526

26-
tpl, err = textwire.NewTemplate(nil)
27+
tpl, err = textwire.NewTemplate(&config.Config{
28+
TemplateExt: ".tw",
29+
DebugMode: true,
30+
})
2731

2832
if err != nil {
2933
fmt.Println(err)
@@ -64,10 +68,10 @@ If your template files are not showing up after you've created them and you are
6468
:::
6569

6670
## Layouts
67-
Defining a layout in Textwire is very simple. You need to create a layout file anywhere inside of your `templates` directory. Many developers just create a `templates/layouts/` directory for different layouts because you might have different layouts like `main.tw.html`, `admin.tw.html`, `user.tw.html`.
71+
Defining a layout in Textwire is very simple. You need to create a layout file anywhere inside of your `templates` directory. Many developers just create a `templates/layouts/` directory for different layouts because you might have different layouts like `main.tw`, `admin.tw`, `user.tw`.
6872

6973
### Reserve space in the layout
70-
The [reserve](/docs/v2/language-elements/statements#reserve-statement) statement (also called directive) is used to reserve a place for dynamic content that you can insert later in the layout. For example, you can reserve a place for the title of the page and then insert it later from `about-me-tw.html` or `contact-us.tw.html`. Here is an example of a layout file:
74+
The [reserve](/docs/v2/language-elements/statements#reserve-statement) statement (also called directive) is used to reserve a place for dynamic content that you can insert later in the layout. For example, you can reserve a place for the title of the page and then insert it later from `about-me.tw` or `contact-us.tw`. Here is an example of a layout file:
7175

7276
```textwire title="templates/layouts/main.tw"
7377
<!DOCTYPE html>
@@ -88,7 +92,7 @@ We reserve spaces for the title and content of the page. These reserved spaces c
8892
### Insert content into reserved space
8993
The `insert` statement (directive) is used to insert content into reserved places. Insert statement can be defined in 2 ways, with and without the body. In the example below, we define the insert for "title" without the body, and for "content" with the body.
9094

91-
Let's take a look at the example how I would define a `home.tw.html` and then I'll explain each part of it:
95+
Let's take a look at the example how I would define a `home.tw` and then I'll explain each part of it:
9296

9397
```textwire title="templates/home.tw"
9498
@use("layouts/main")

versioned_docs/version-v2/language-elements/language-elements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Textwire is designed to be intuitive for Go developers, offering a syntax that f
1212

1313
Textwire’s syntax is straightforward and easy to learn. Below are the key rules for writing Textwire code:
1414

15-
- **File Extensions**: All HTML files intended for Textwire parsing must have a `.tw.html` or `.tw` extension. The default is `.tw.html`, but using the `.tw` extension is recommended.
15+
- **File Extensions**: All HTML files intended for Textwire parsing must have a `.tw` extension.
1616
- **Code Placement**: All Textwire code must either:
1717
- Be enclosed within `{{ }}` braces, or
1818
- Start with the `@` symbol.

0 commit comments

Comments
 (0)