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: versioned_docs/version-v3/faq.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,17 +11,17 @@ Welcome to our FAQ page, where we address the most common questions and concerns
11
11
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.
12
12
13
13
## 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.
15
15
16
16
## How does Textwire Parse Files?
17
17
Textwire has its own unique chain of turning your text files into final output. We do it in 4 steps:
18
18
19
19
1.**Tokenizing** your Textwire template into tokens.
20
20
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 eachother.
22
22
4.**Evaluating** turns connected AST nodes into final text output.
23
23
24
-
All the non-Textwirespecific 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:
25
25
26
26
```textwire
27
27
<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
32
32
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.
33
33
34
34
## 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.
36
36
37
37
## Prevent Visitors from Seeing Error
38
38
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.
@@ -236,17 +235,13 @@ Here’s a simple example of using a component:
236
235
</div>
237
236
```
238
237
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
-
243
238
:::info Component path alias
244
239
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/`.
245
240
:::
246
241
247
242
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.
248
243
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:
250
245
251
246
```textwire title="home.tw"
252
247
<ul>
@@ -256,7 +251,10 @@ The second optional argument is a [Textwire object](/docs/v3/language-elements/l
256
251
</ul>
257
252
```
258
253
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.
0 commit comments