Skip to content

Questions

What Exactly is Textwire?

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.

  • ✅ We're committed to performance optimization and better error handling
  • ✅ Our priority is keeping the language core solid and reliable
  • ❌ We steer clear of shiny features that would only add bloat

How Textwire Parses Text Files?

Textwire has it's own lexing and parsing engine that is used to parse text files. It reads the text file line by line and converts it into a tree of nodes. Each node represents a part of the text file and can be used to generate the final output.

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. The only parts that are parsed are the Textwire specific parts, like directives and expressions like:

textwire
{{ "Hello, World!".upper() }}

That's why Textwire is fast and efficient, as it only parses the parts that are necessary and leaves the rest as is.

Why It's Best to Prevent Visitors of Your Site From Seeing the Result of the Function Output When an Error Occurs?

When an error occurs in your function, the output may be incorrect or misleading. Displaying this faulty output to users can result in confusing information, broken layouts, or even unintentionally exposing sensitive data.

For example, a function might return partial or incorrect data due to an error in the logic or wrong inputs. If this faulty output is displayed to your site’s visitors, it could negatively impact the user experience by showing inaccurate information or broken page elements.

Moreover, displaying incorrect output can also pose security risks, as it might reveal unintended details about the internal workings of your system, or expose raw data that wasn’t meant to be shown. By hiding incorrect output when an error occurs, you ensure that visitors only see validated, correct content, maintaining both the integrity of your site’s data and the trustworthiness of your user experience.

What is the Difference Between Directives and Statements in Textwire?

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:

  • All directives are statements, but not all statements are directives
  • Directives start with the @ symbol, while statements is a general term for parts of code that perform and action and do not return a value

Read More

You can read about statements in the Statements section of the documentation.

For example, 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.