Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to specify file system (#80)
* Add option to specify a file system This option can be used to load files other than the local file system. This is useful if templates are stored within the binary. * Make default file system public * Update readme with new option
- Loading branch information
Showing
3 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package render | ||
|
||
import ( | ||
"io/ioutil" | ||
"path/filepath" | ||
) | ||
|
||
type FileSystem interface { | ||
Walk(root string, walkFn filepath.WalkFunc) error | ||
ReadFile(filename string) ([]byte, error) | ||
} | ||
|
||
type LocalFileSystem struct{} | ||
|
||
func (LocalFileSystem) Walk(root string, walkFn filepath.WalkFunc) error { | ||
return filepath.Walk(root, walkFn) | ||
} | ||
|
||
func (LocalFileSystem) ReadFile(filename string) ([]byte, error) { | ||
return ioutil.ReadFile(filename) | ||
} |
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