-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
94 additions
and
91 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/infogulch/xtemplate | ||
|
||
go 1.21.0 | ||
go 1.21.3 | ||
|
||
require ( | ||
github.com/BurntSushi/toml v1.3.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/infogulch/xtemplate/internal | ||
|
||
go 1.21.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package internal | ||
|
||
import ( | ||
"html/template" | ||
"io/fs" | ||
) | ||
|
||
var RegisteredFuncMaps map[string]template.FuncMap = make(map[string]template.FuncMap) | ||
|
||
var RegisteredFS map[string]fs.FS = make(map[string]fs.FS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module github.com/infogulch/xtemplate/register | ||
|
||
go 1.21.3 | ||
|
||
require github.com/infogulch/xtemplate/internal v0.0.0 | ||
|
||
replace github.com/infogulch/xtemplate/internal v0.0.0 => ../internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package register | ||
|
||
import ( | ||
"fmt" | ||
"html/template" | ||
"io/fs" | ||
|
||
"github.com/infogulch/xtemplate/internal" | ||
) | ||
|
||
func RegisterFuncMap(name string, funcs template.FuncMap) { | ||
if existing, ok := internal.RegisteredFuncMaps[name]; ok { | ||
panic(fmt.Sprintf("funcmap named '%s' already registered as '%+v'", name, existing)) | ||
} | ||
internal.RegisteredFuncMaps[name] = funcs | ||
} | ||
|
||
func RegisterFS(name string, fs fs.FS) { | ||
if existing, ok := internal.RegisteredFS[name]; ok { | ||
panic(fmt.Sprintf("fs named '%s' already registered as '%+v'", name, existing)) | ||
} | ||
internal.RegisteredFS[name] = fs | ||
} |