Skip to content

Commit

Permalink
fix - package import name
Browse files Browse the repository at this point in the history
  • Loading branch information
noelukwa committed Feb 12, 2024
1 parent 8f52807 commit ded8961
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
# tempest
# tempest

*Made out of neccessity and frustration* 😩

## Features

- Use go templates in your app without repeating the parsing logic over and over.
- Use any template supported by go html/template package.
- Use `go:embed` to embed template files in your binary.
- Parse templates once.

## Usage

In order for tempest to parse templates, three conditions must be met.
1. Templates must be embeded

1. Templates must be embeded
2. The name of the template used for layouts should be `layouts.<extention>`, otherwise, it should be stated with custom config.
3. The name of the folder containing partial templates should be "inludes", otherwise, it should be stated with custom config

*📝 For requirements 2 and 3, see [examples/with-conf](https://github.com/noelukwa/tempest)*

**Requirements**


**Requirements**
- Fair knowledge of go [html/template](https://pkg.go.dev/html/template) package.
- Go version >= 1.16


## Example

Lets say you have a folder structure like this

```
.
├── main.go
Expand All @@ -40,14 +44,15 @@ Lets say you have a folder structure like this
```

In your main.go file, you can do something like this

```go
package main

import (
"embed"
"log"

"github.com/noelukwa/tempest"
"github.com/uchexgod/tempest"
)

var (
Expand Down Expand Up @@ -78,6 +83,7 @@ func main() {
```

## Template Directory Parsing

The template files in the `templates` directory above will be grouped as follows

```
Expand All @@ -104,6 +110,7 @@ The template files in the `templates` directory above will be grouped as follows
```

### html/template basics

*When using nested layouts, the child layout's `define` block name should correspond to the parent layout's `block` name.*

```html
Expand All @@ -112,6 +119,7 @@ The template files in the `templates` directory above will be grouped as follows
{{ block "content" . }}{{ end }}
</main>
```

```html
<!-- templates/admin/layout.html -->
{{ define "content" }}
Expand All @@ -122,4 +130,3 @@ The template files in the `templates` directory above will be grouped as follows
```

Further Read: [Go html/template package](https://pkg.go.dev/html/template)

2 changes: 1 addition & 1 deletion examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

"github.com/noelukwa/tempest"
"github.com/uchexgod/tempest"
)

//go:embed views
Expand Down
2 changes: 1 addition & 1 deletion examples/with-conf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

"github.com/noelukwa/tempest"
"github.com/uchexgod/tempest"
)

//go:embed views
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/noelukwa/tempest
module github.com/uchexgod/tempest

go 1.18
2 changes: 1 addition & 1 deletion tempest.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// "net/http"
// "os"
//
// "github.com/noelukwa/tempest"
// "github.com/uchexgod/tempest"
// )
//
// //go:embed views
Expand Down
4 changes: 2 additions & 2 deletions tempest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"strings"
"testing"

"github.com/noelukwa/tempest"
"github.com/noelukwa/tempest/test"
"github.com/uchexgod/tempest"
"github.com/uchexgod/tempest/test"
)

func TestLoadFs(t *testing.T) {
Expand Down

0 comments on commit ded8961

Please sign in to comment.