SetBaseDir sets the template's base directory. This directory will be used for any relative path in filters, tags and From*-functions to determine your template. See the comment for NewLocalFileSystemLoader as well.
(path string)
| 68 | // be used for any relative path in filters, tags and From*-functions to determine |
| 69 | // your template. See the comment for NewLocalFileSystemLoader as well. |
| 70 | func (fs *LocalFilesystemLoader) SetBaseDir(path string) error { |
| 71 | // Make the path absolute |
| 72 | if !filepath.IsAbs(path) { |
| 73 | abs, err := filepath.Abs(path) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | path = abs |
| 78 | } |
| 79 | |
| 80 | // Check for existence |
| 81 | fi, err := os.Stat(path) |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | if !fi.IsDir() { |
| 86 | return fmt.Errorf("the given path '%s' is not a directory", path) |
| 87 | } |
| 88 | |
| 89 | fs.baseDir = path |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | // Get reads the path's content from your local filesystem. |
| 94 | func (fs *LocalFilesystemLoader) Get(path string) (io.Reader, error) { |