Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crufter/require
The Require Go package allows you to do file inclusion in any file/string.
https://github.com/crufter/require
Last synced: 22 days ago
JSON representation
The Require Go package allows you to do file inclusion in any file/string.
- Host: GitHub
- URL: https://github.com/crufter/require
- Owner: crufter
- Created: 2012-05-25T07:15:55.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-07T05:36:04.000Z (over 12 years ago)
- Last Synced: 2024-11-30T21:48:47.115Z (23 days ago)
- Language: Go
- Size: 121 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Require
=======The Require Go package allows you to do file inclusion in any file/string.
Usage
=======```
package mainimport(
"github.com/opesun/require"
"fmt"
)func main() {
v, err := require.RSimple("/usr", "index.html")
if err != "" {
panic(err)
}
// If index.html contains "{{require header.html}} text here {{require footer.html}}"
// and header.html contains "header", footer.html contains "footer"
// then
fmt.Println(v)
// v will be the string "header text here footer"
}
```The RSimple method is a thin wrapper around the R method.
The R method needs a function with a signature of func(string) ([]byte,error) as its last parameter, where you can provide your very own function which gets the content of the required files,
so you can implement your own caching mechanism, and things like that.