Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ujstor committed Sep 17, 2024
1 parent 258957d commit 1347a92
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
19 changes: 13 additions & 6 deletions cmd/template/framework/files/README.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,38 @@ These instructions will get you a copy of the project up and running on your loc

## MakeFile

run all make commands with clean tests
Run build make command with tests
```bash
make all build
make all
```

build the application
Build the application
```bash
make build
```

run the application
Run the application
```bash
make run
```

{- if and (ne .DBDriver "none") (ne .DBDriver "sqlite") }}
Create DB container
```bash
make docker-run
```

Shutdown DB container
Shutdown DB Container
```bash
make docker-down
```

DB Integrations Test:
```bash
make itest
```
{{ - end }}

live reload the application
```bash
make watch
Expand All @@ -46,4 +53,4 @@ make test
clean up binary from the last build
```bash
make clean
```
```
2 changes: 1 addition & 1 deletion cmd/template/framework/files/makefile.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple Makefile for a Go project

# Build the application
all: build
all: build test

{{- if or .AdvancedOptions.htmx .AdvancedOptions.tailwind }}
{{- if .OSCheck.UnixBased }}
Expand Down
32 changes: 31 additions & 1 deletion docs/docs/advanced-flag/htmx-templ.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,38 @@ templ generate
make run
```

## Makefile

Automates templ with Makefile entries, which are automatically created if the htmx advanced flag is used.
It detects if templ is installed or not and generates templates with the make build command.
Both Windows and Unix-like OS are supported.

```bash
all: build

templ-install:
@if ! command -v templ > /dev/null; then \
read -p "Go's 'templ' is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/a-h/templ/cmd/templ@latest; \
if [ ! -x "$$(command -v templ)" ]; then \
echo "templ installation failed. Exiting..."; \
exit 1; \
fi; \
else \
echo "You chose not to install templ. Exiting..."; \
exit 1; \
fi; \
fi

build: templ-install
@echo "Building..."
@templ generate
@go build -o main cmd/api/main.go
```

## Templating

Templates are generated using the `templ generate` command after project creation. These templates are then compiled into Go code for efficient execution.

You can test HTMX functionality on `localhost:port/web` endpoint.
You can test HTMX functionality on `localhost:PORT/web` endpoint.
2 changes: 1 addition & 1 deletion docs/docs/advanced-flag/tailwind.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The The idea is to avoid using Node.js and npm to build output.css.

The Makefile will have entries for downloading and compiling CSS. It will automatically detect the OS and download the latest release from the [official repository](https://github.com/tailwindlabs/tailwindcss/releases).

## Linux Makefile example:
## Linux Makefile Example
```bash
all: build
templ-install:
Expand Down

0 comments on commit 1347a92

Please sign in to comment.