Skip to content

Commit

Permalink
allow use of afero.Fs
Browse files Browse the repository at this point in the history
  • Loading branch information
dvaumoron committed Oct 20, 2023
1 parent a2bfe46 commit 5b6d7b4
Show file tree
Hide file tree
Showing 4 changed files with 505 additions and 23 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ And use it in two step :

```Go
// parse templates
renderer, err := partrenderer.MakePartRenderer(componentsPath, viewsPath, fileExt, customFuncs)
renderer, err := partrenderer.MakePartRenderer(componentsPath, viewsPath)
// and use them
err = renderer.ExecuteTemplate(writer, viewName, data)
```
Expand All @@ -27,8 +27,6 @@ The first call with :

- componentsPath indicate a directory to walk in order to load all component templates
- viewsPath indicate a directory to walk in order to load all view templates (which can see components)
- fileExt can be ".html" (filter readed files, a value without a starting dot have one added automatically)
- customFuncs is a [FuncMap](https://pkg.go.dev/text/template#FuncMap) to register your custom template functions

The second call has the same signature as [Template.ExecuteTemplate](https://pkg.go.dev/text/template#Template.ExecuteTemplate) where viewName has no extention ("hello/index" for an index.html file in hello folder) and can have a part selector (like in "hello/index#body", without this selector "root" is used).

Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module github.com/dvaumoron/partrenderer

go 1.21.3

require github.com/spf13/afero v1.10.0

require golang.org/x/text v0.3.7 // indirect
Loading

0 comments on commit 5b6d7b4

Please sign in to comment.