Skip to content

Commit 81e25c4

Browse files
committed
docs: improve
1 parent 5ee9ab4 commit 81e25c4

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

versioned_docs/version-v3/faq.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ Welcome to our FAQ page, where we address the most common questions and concerns
1111
Here, you’ll find explanations, solutions to common problems, and best practices to make the most of your experience. If you don’t find the answer you’re looking for, feel free to reach out to us by creating an [issue on GitHub](https://github.com/textwire/textwire.github.io/issues/new) and we’ll be happy to help and update the FAQ with your question to help others.
1212

1313
## What exactly is Textwire?
14-
Textwire is a domain-specific language designed to be used with Go. Other Go's templating engines that I've used were never giving me joy and flexibility to write frontend, Textwire was created to fill that gap. It is a simple and stability driven language that needs to be used for your app. See how to [Get Started](/docs/v3/get-started) with Textwire.
14+
Textwire is a domain-specific language designed to be used with Go. Unlike other Go templating engines I've used, Textwire provides the joy and flexibility needed for frontend development. It is a simple and stable language that should be used for your app. See how to [Get Started](/docs/v3/get-started) with Textwire.
1515

1616
## How does Textwire Parse Files?
1717
Textwire has its own unique chain of turning your text files into final output. We do it in 4 steps:
1818

1919
1. **Tokenizing** your Textwire template into tokens.
2020
2. **Parsing** turns tokens into [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) nodes.
21-
3. **Linking** connects related AST nodes to each-other.
21+
3. **Linking** connects related AST nodes to each other.
2222
4. **Evaluating** turns connected AST nodes into final text output.
2323

24-
All the non-Textwire specific parts of the text file are not parsed as HTML, XML or any other format. They are treated as plain text and are not modified in any way. Even whitespace in your text is preserved in the final output. Only Textwire-specific parts are processed:
24+
All non-Textwire-specific parts of the text file are treated as plain text and are not parsed as HTML, XML, or any other format. They remain unmodified in the final output, including whitespace preservation. Only Textwire-specific parts are processed:
2525

2626
```textwire
2727
<h1>Textwire seems cool</h1>
@@ -32,7 +32,7 @@ All the non-Textwire specific parts of the text file are not parsed as HTML, XML
3232
In the example above, only `{{ "Hello, World!".upper() }}` part will be evaluated. That's why Textwire is fast, as it only parses the parts that are necessary and leaves the rest as is.
3333

3434
## Is Textwire a Templating Engine?
35-
Textwire is not exactly a templating engine. It is a Domain-specific language (DSL) written in Go. It is designed to be used with Go programs to provide elegant and easy to use syntax for working with front-end. It's a good alternative to other templating engines for Go since it's performant and optimized.
35+
Textwire is not exactly a templating engine. It is a Domain-specific language (DSL) written in Go. It is designed to be used with Go programs to provide elegant and easy-to-use syntax for working with frontend. It's a good alternative to other templating engines for Go since it's performant and optimized.
3636

3737
## Prevent Visitors from Seeing Error
3838
When an error occurs in your function, the output may be incorrect or misleading. Displaying faulty output to users can result in confusing information, broken layouts, or unintentional exposure of sensitive data.

versioned_docs/version-v3/language-elements/statements.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ description: Learn about different statements in Textwire, including if statemen
77

88
# Statements
99

10-
- Statements
11-
- [If Statement](#if-statement) `@if(x == 1)`
12-
- [Variable Declaration](#variable-declaration) `{{ x = 5 }}`
13-
- [Use Statement](#use-statement) `@use("layouts/main")`
14-
- [Insert Statement](#insert-statement) `@insert("title", "Home")`
15-
- [Reserve Statement](#reserve-statement) `@reserve("title")`
16-
- [For Statement](#for-statement) `@for(i = 0; i < 2; i++)`
17-
- [Each Statement](#each-statement) `@each(name in names)`
18-
- [Component](#component) `@component("components/post-card")`
19-
- [Component Slots](#component-slots) `@slot('footer')`
20-
- [Dump Directive](#dump-directive) `@dump(users, page)`
10+
- [If Statement](#if-statement) `@if(x == 1)`
11+
- [Variable Declaration](#variable-declaration) `{{ x = 5 }}`
12+
- [Use Statement](#use-statement) `@use("layouts/main")`
13+
- [Insert Statement](#insert-statement) `@insert("title", "Home")`
14+
- [Reserve Statement](#reserve-statement) `@reserve("title")`
15+
- [For Statement](#for-statement) `@for(i = 0; i < 2; i++)`
16+
- [Each Statement](#each-statement) `@each(name in names)`
17+
- [Component](#component) `@component("components/post-card")`
18+
- [Component Slots](#component-slots) `@slot('footer')`
19+
- [Dump Directive](#dump-directive) `@dump(users, page)`
2120

2221
## If Statement
2322

@@ -236,17 +235,13 @@ Here’s a simple example of using a component:
236235
</div>
237236
```
238237

239-
:::warning
240-
Component cannot have empty body and be like `@component("components/post-card", { post })@end`. In this situations it's important to remove `@end` token.
241-
:::
242-
243238
:::info Component path alias
244239
If your components are located in the `components` directory, you can use the `~` alias to reference them. For example, `@component("~post-card", { post })` instead of `@component("components/post-card", { post })`. Behind the scenes, the `~` alias will be replaced with `components/`.
245240
:::
246241

247242
The first argument of the `@component` directive is a path to the component file relative to the `TemplateDir` parameter that you set in the config.
248243

249-
The second optional argument is a [Textwire object](/docs/v3/language-elements/literals#object) that you want to pass to the component. Here is another example of using a component with a second argument:
244+
The second optional argument is an [object](/docs/v3/language-elements/literals#object) that you want to pass to the component. Here is another example of using a component with a second argument:
250245

251246
```textwire title="home.tw"
252247
<ul>
@@ -256,7 +251,10 @@ The second optional argument is a [Textwire object](/docs/v3/language-elements/l
256251
</ul>
257252
```
258253

259-
You can also use slots in components to pass content to the component. Read about slots in the next section.
254+
### Imporant Notes
255+
1. You can include layout file into components using [`@use`](/docs/v3/language-elements/statements#use-statement) statement, but it can make your templates more complex and harder to maintain. We recommend to avoid using layouts in components and keep them simple.
256+
2. Component cannot have empty body and be like `@component("post", { post })@end`. In this situations it's important to remove `@end` token to avoid parsing errors.
257+
3. You can use [slots](/docs/v3/language-elements/statements#component-slots) in components to pass content to the component file.
260258

261259
## Component Slots
262260

0 commit comments

Comments
 (0)