|
1 | 1 | --- |
2 | 2 | title: FAQ - v3 |
3 | | -description: Find answers to common questions and helpful tips in our FAQ section. Get quick solutions to common issues and learn more about our services |
| 3 | +description: Find answers to common questions about Textwire, a templating engine for Go |
4 | 4 | --- |
5 | 5 |
|
6 | | -# Frequently Asked Questions (FAQ) |
| 6 | +# Frequently Asked Questions |
7 | 7 |
|
8 | | -Welcome to our FAQ page, where we address the most common questions and concerns about using Textwire. Whether you’re new to **Textwire** or a seasoned user, the FAQ is designed to provide quick and helpful answers to your most pressing queries. |
| 8 | +Find answers to common questions about Textwire. If you don't find what you're looking for, feel free to [open an issue on GitHub](https://github.com/textwire/textwire.github.io/issues/new). |
9 | 9 |
|
10 | | -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. |
| 10 | +## What is Textwire? |
11 | 11 |
|
12 | | -## What Exactly is Textwire? |
| 12 | +Textwire is a templating engine for Go. You implement your business logic in Go and pass data to Textwire templates to generate dynamic content. It is designed to be fast, efficient, and easy to use. |
13 | 13 |
|
14 | | -Textwire is a templating engine for Go programming language. You do all of your business logic in Go and pass data to Textwire templates to generate dynamic content. It is designed to be fast, efficient, and easy to use. |
15 | | - |
16 | | -- ✅ We're committed to performance optimization and better error handling |
17 | | -- ✅ Our priority is keeping the language core solid and reliable |
18 | | -- ❌ We steer clear of shiny features that would only add bloat |
| 14 | +- Committed to performance optimization and solid error handling |
| 15 | +- Focused on keeping the language core reliable |
| 16 | +- Avoids features that add unnecessary complexity |
19 | 17 |
|
20 | 18 | ## How Does Textwire Parse Files? |
21 | 19 |
|
22 | | -Textwire has its own unique chain of turning your text files into final output. We do it in 4 steps: |
| 20 | +Textwire processes templates in four stages: |
23 | 21 |
|
24 | | -1. **Tokenizing** your Textwire template into tokens. |
25 | | -2. **Parsing** turns tokens into [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) nodes. |
26 | | -3. **Linking** connects related AST nodes to each other. |
27 | | -4. **Evaluating** turns connected AST nodes into final text output. |
| 22 | +1. **Tokenizing** - Breaks the template into tokens |
| 23 | +2. **Parsing** - Converts tokens into [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) nodes |
| 24 | +3. **Linking** - Connects related AST nodes |
| 25 | +4. **Evaluating** - Generates the final text output |
28 | 26 |
|
29 | | -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: |
| 27 | +Non-Textwire content is treated as plain text and passes through unchanged, including whitespace. Only Textwire-specific syntax is processed: |
30 | 28 |
|
31 | 29 | ```textwire |
32 | | -<h1>Textwire seems cool</h1> |
| 30 | +<h1>Welcome</h1> |
33 | 31 | {{ "Hello, World!".upper() }} |
34 | | -<p>I would use it in production<p> |
| 32 | +<p>Ready for production</p> |
35 | 33 | ``` |
36 | 34 |
|
37 | | -In the example above, only <code v-pre>{{ "Hello, World!".upper() }}</code> 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. |
| 35 | +In the example above, only <code v-pre>{{ "Hello, World!".upper() }}</code> is evaluated. This selective parsing is what makes Textwire fast compared to other templating engines. |
38 | 36 |
|
39 | | -## Prevent Visitors from Seeing Error |
| 37 | +## Why Hide Error Output from Visitors? |
40 | 38 |
|
41 | | -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. |
| 39 | +When a function error occurs, the output may be incorrect or misleading. Displaying faulty output to users can result in: |
42 | 40 |
|
43 | | -Hiding incorrect output when errors occur ensures that visitors only see validated, correct content, maintaining both data integrity and user trust while preventing potential security risks. |
| 41 | +- Confusing information or broken layouts |
| 42 | +- Unintentional exposure of sensitive data |
| 43 | +- Security vulnerabilities |
44 | 44 |
|
45 | | -## The Difference Between Directives and Statements |
| 45 | +For example, a function might return partial or incorrect data due to a logic error or invalid input. Displaying this to visitors negatively impacts user experience and may reveal internal system details. |
46 | 46 |
|
47 | | -Directives and statements are the core of Textwire language. They are used to define the structure and behavior of your text files. However, there are some key differences between them: |
| 47 | +By hiding incorrect output when errors occur, you ensure visitors only see validated, correct content. This maintains data integrity, user trust, and prevents potential security risks. |
48 | 48 |
|
49 | | -- All directives are statements, but not all statements are directives |
50 | | -- Directives start with the `@` symbol, while statements are a general term for parts of code that perform an action and do not return a value |
| 49 | +## Directives vs Statements |
51 | 50 |
|
52 | | -:::info Read More |
53 | | -You can read about statements in the [Statements](/v3/language-elements/directives) section of the documentation. |
54 | | -::: |
| 51 | +Directives and statements are fundamental elements of the Textwire language. Both define the structure and behavior of your templates, but they differ in form: |
55 | 52 |
|
56 | | -For example, `{{ x = 5 }}` is a statement that assigns the value `5` to the variable `x`. On the other hand, `@use('~main')` is a directive and a statement at the same time, as it includes the layout `main` in the current file and doesn't return a value. |
| 53 | +- **Directives** start with the `@` symbol (e.g., `@use`, `@if`, `@for`) |
| 54 | +- **Statements** are expressions that perform an action but don't return a value (e.g., <code v-pre>{{ x = 5 }}</code>) |
| 55 | + |
| 56 | +:::info Learn More |
| 57 | +See the [Directives](/v3/language-elements/directives) section for a complete reference. |
| 58 | +::: |
0 commit comments