You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/2024-10-24-textwire-v2.1.0-release-notes/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ Regarding improvements, I placed a strong emphasis on proper error handling. I c
50
50
51
51
- 🐛 **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()) }}`.
52
52
- 🧑💻 **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'`.
54
54
- 🧑💻 **Enhanced Error Handling for Division by Zero:** Improved error messages for division-by-zero cases, replacing previous vague messages with more meaningful ones.
55
55
- 🧑💻 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)
56
56
@@ -65,4 +65,4 @@ Some very small changes were made to the Textwire that don't effect any function
65
65
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! 🚀
66
66
67
67
## 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! 🚀
Copy file name to clipboardExpand all lines: versioned_docs/version-v2/guides/template-usage.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,14 +16,18 @@ import (
16
16
"net/http"
17
17
18
18
"github.com/textwire/textwire/v2"
19
+
"github.com/textwire/textwire/v2/config"
19
20
)
20
21
21
22
vartpl *textwire.Template
22
23
23
24
funcmain() {
24
25
varerrerror
25
26
26
-
tpl, err = textwire.NewTemplate(nil)
27
+
tpl, err = textwire.NewTemplate(&config.Config{
28
+
TemplateExt: ".tw",
29
+
DebugMode: true,
30
+
})
27
31
28
32
if err != nil {
29
33
fmt.Println(err)
@@ -64,10 +68,10 @@ If your template files are not showing up after you've created them and you are
64
68
:::
65
69
66
70
## 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`.
68
72
69
73
### 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:
71
75
72
76
```textwire title="templates/layouts/main.tw"
73
77
<!DOCTYPE html>
@@ -88,7 +92,7 @@ We reserve spaces for the title and content of the page. These reserved spaces c
88
92
### Insert content into reserved space
89
93
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.
90
94
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:
Copy file name to clipboardExpand all lines: versioned_docs/version-v2/language-elements/language-elements.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Textwire is designed to be intuitive for Go developers, offering a syntax that f
12
12
13
13
Textwire’s syntax is straightforward and easy to learn. Below are the key rules for writing Textwire code:
14
14
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.
16
16
-**Code Placement**: All Textwire code must either:
0 commit comments