Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: minor clarity and spelling fixes #185

Merged
merged 4 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Running your first templ application

Lets update the previous application to serve HTML over HTTP instead of writing it to the terminal.
Let's update the previous application to serve HTML over HTTP instead of writing it to the terminal.

## Create a web server

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/03-syntax-and-usage/02-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {
```

:::info
templ automatically minifies HTML reponses, output is shown formatted for readability.
templ automatically minifies HTML responses, output is shown formatted for readability.
:::

## Tags must be closed
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/03-syntax-and-usage/03-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ templ Button(text string) {

## CSS attributes

CSS handling is discussed in detail at [CSS style management](css-style-management).
CSS handling is discussed in detail in [CSS style management](css-style-management).
2 changes: 1 addition & 1 deletion docs/docs/03-syntax-and-usage/07-loops.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For loops

templ supports iterating over slices, arrays and channels etc. using the standard Go `for` loop.
Use the standard Go `for` loop for iteration.

```templ title="component.templ"
package main
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/03-syntax-and-usage/09-css-style-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ templ button(text string) {

## Class expression

To use a variables as the name of a CSS class, use a CSS expression.
To use a variable as the name of a CSS class, use a CSS expression.

```templ title="component.templ"
package main
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/04-core-concepts/01-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ templ follows the same rules as Go. If a `templ` block starts with an uppercase

## Code-only components

Since templ Components ultimately implement the `templ.Component`, any code that implments the interface can be used in place of a templ component generated from a `*.templ` file.
Since templ Components ultimately implement the `templ.Component`, any code that implements the interface can be used in place of a templ component generated from a `*.templ` file.

```go
package main
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/04-core-concepts/02-template-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ templ generate

The `templ generate` command will recurse into subdirectories and generate Go code for every `*.templ` file it finds.

The command will output a list of files that it processed, how long it took, and a total elapsed time.
The command will output a list of files that it processed, how long it took, and the total elapsed time.

```
main.templ complete in 897.292µs
Expand All @@ -19,7 +19,7 @@ Generated code for 1 templates with 0 errors in 1.291292ms

The `templ generate` command has a `--help` option that prints advanced options.

These include the ability to generate code a single file, or choose the parallel workers that `templ generate` uses to create Go files.
These include the ability to generate code for a single file and to choose the number of parallel workers that `templ generate` uses to create Go files.

By default `templ generate` uses the number of CPUs that your machine has installed.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The output will always be the date and time that the web server was started up,
To display the current time, we could update the component to use the `time.Now()` function itself, but this would limit the reusability of the component. It's better when components take parameters for their display values.

:::tip
Good templ components are idempotent, pure functions - they don't rely on data that's not passed in as parameters. As long as the parameters are the same, they always return the same HTML - they don't rely on any network calls or disk access.
Good templ components are idempotent, pure functions - they don't rely on data that is not passed in through parameters. As long as the parameters are the same, they always return the same HTML - they don't rely on any network calls or disk access.
:::

## Displaying dynamic data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ flowchart TD

## Updating global state

First, define a HTML form post with two buttons. One for global, and for one per-user.
First, define a HTML form post with two buttons. One to update a global state, and one for a per-user state.

```templ title="components.templ"
package main
Expand Down Expand Up @@ -101,7 +101,7 @@ func main() {
```

:::note
In this example, the global state is stored in RAM, and will be lost when the web server reboots. To support load balanced web servers, and stateless function deployments, you might consider storing the state in a data store such as Redis, DynamoDB, or Cloud Firestore.
In this example, the global state is stored in RAM, and will be lost when the web server reboots. To support load-balanced web servers, and stateless function deployments, you might consider storing the state in a data store such as Redis, DynamoDB, or Cloud Firestore.
:::

## Adding per-user session state
Expand Down Expand Up @@ -196,11 +196,11 @@ func main() {
```

:::note
Incrementing a count by reading and setting the value is not an atomic operation (not thread safe). In a production application, to increment a per-user count you may wish to use a database that provides a transactional increment operation.
Incrementing a count by reading and setting the value is not an atomic operation (not thread-safe). In a production application, to increment a per-user count you may wish to use a database that provides a transactional increment operation.
:::

:::note
The default behaviour of `scs` is to store session data in RAM, which isn't suitable for stateless function deployments, or load balanced applications, but the library supports a range of backend storage solutions.
The default behaviour of `scs` is to store session data in RAM, which isn't suitable for stateless function deployments, or load-balanced applications, but the library supports a range of backend storage solutions.
:::

Complete source code including AWS CDK code to set up the infrastructure is available at https://github.com/a-h/templ/tree/main/examples/counter
4 changes: 2 additions & 2 deletions docs/docs/05-server-side-rendering/03-htmx.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HTMX

https://htmx.org can be used to selectively replace content within a web page, instead of replacing the whole page in the browser. This avoids "full-page postbacks", where the whole of the browser window is updated when a button is clicked, and results in better user experience by reducing sreen "flicker", or losing scroll position.
https://htmx.org can be used to selectively replace content within a web page, instead of replacing the whole page in the browser. This avoids "full-page postbacks", where the whole of the browser window is updated when a button is clicked, and results in a better user experience by reducing screen "flicker", or losing scroll position.

## Usage

Expand All @@ -20,7 +20,7 @@ Then add a `<script>` tag to the `<head>` section of your HTML with the `src` at
```

:::info
Advanced HTMX installation and usage is convered in the user guide at https://htmx.org.
Advanced HTMX installation and usage help is covered in the user guide at https://htmx.org.
:::

## Count example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Component interface {

In Go, the `io.Writer` interface is implemented by many built-in types in the standard library, including `os.File` (files), `os.Stdout`, and `http.ResponseWriter` (HTTP responses).

This make it easy to use templ components in a variety of contexts to generate HTML.
This makes it easy to use templ components in a variety of contexts to generate HTML.

To render static HTML files using templ component, first create a new Go project.

Expand All @@ -36,7 +36,7 @@ go mod init github.com/a-h/templ-examples/static-generator

To use it, create a `hello.templ` file containing a component.

Components are functions that contain templ elements, markup, and `if`, `switch`, and `for` Go expressions.
Components are functions that contain templ elements, markup, `if`, `switch` and `for` Go expressions.

```templ title="hello.templ"
package main
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/06-static-rendering/02-blog-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Top May Day Activities in the UK:
* Dancing around the Maypole, a traditional folk activity
* Attending local village fetes and fairs
* Watching or participating in Morris dancing performances
* Enjoying the day off as a public holiday, known as Early May Bank Holiday
* Enjoying having a day off from the Early May Bank Holiday
a-h marked this conversation as resolved.
Show resolved Hide resolved
`,
},
}
Expand Down Expand Up @@ -235,7 +235,7 @@ While each content page contains the HTML generated from the markdown, and the s
Watching or participating in Morris dancing performances
</li>
<li>
Enjoying the day off as a public holiday, known as Early May Bank Holiday
Enjoying having a day off from the Early May Bank Holiday
a-h marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/06-static-rendering/03-deploying-static-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Ways you could host your site include:
* AWS Amplify
* Firebase Hosting

Typically specialist static hosting services are more cost effective than VM or Docker based services, due to the less complex compute and networking requirements.
Typically specialist static hosting services are more cost-effective than VM or Docker-based services, due to the less complex compute and networking requirements.

Most require you to commit your code to a source repository, with a build process being triggered on commit, but Fly.io allows you to deploy easily from the CLI.

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/07-project-structure/01-project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ graph LR
* Does not contain application logic itself
* Uses `services` that carry out application logic
* Takes the responses from `services` and uses `components` to render HTML
* Creates HTTP repsonses
* Creates HTTP responses
* Services
* Carries out application logic such as orchestrating API calls, or making database calls
* Does not do anything related to HTML or HTTP
Expand Down Expand Up @@ -74,7 +74,7 @@ type DefaultHandler struct {
}
```

Changing the signature of `New` to add a new dependency will result in a compilation error that shows you all affected code in your application.
Changing the signature of `New` to add a new dependency will result in a compilation error that shows you all the affected code in your application.

:::tip
Dependency injection frameworks are not typically used in Go. If you're coming from a language like C# or Java, this may seem unusual to you, but go with it, you don't need one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

AWS Lambda is a great way to host templ applications.

The example at https://github.com/a-h/templ/tree/main/examples/counter includes example AWS CDK code for deploying onto AWS Lambda.
The example at https://github.com/a-h/templ/tree/main/examples/counter includes AWS CDK code for deploying onto AWS Lambda.

See the `/cdk` directory for the details.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/10-security/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Injection attacks

templ is designed to prevent user provided data from being used to inject vulnerabilities.
templ is designed to prevent user-provided data from being used to inject vulnerabilities.

`<script>` and `<style>` tags could allow user data to inject vulnerabilities, so variables are not permitted in these sections.

Expand Down