0
0
Fork 0

add template path from config file

This commit is contained in:
Gibheer 2014-08-09 00:19:45 +02:00
parent e909aea534
commit 0ce5d76e07
4 changed files with 8 additions and 1 deletions

View File

@ -16,7 +16,7 @@ func boot_system() (*lib.Environment, error) {
if err != nil {
return env, err
}
env.Template, err = lib.LoadTemplates(`templates`)
env.Template, err = lib.LoadTemplates(settings.Templates)
if err != nil {
return env, err
}

View File

@ -3,3 +3,6 @@
# more information can be obtained on the github page of the driver
# http://godoc.org/github.com/lib/pq
connection: user=zeroblog password=foobar sslmode=disable
# the base template directory
templates: templates

View File

@ -8,6 +8,7 @@ import (
type Settings struct {
Connection string
Templates string
}
type Environment struct {

View File

@ -1,6 +1,7 @@
package lib
import (
"errors"
"log"
"io/ioutil"
"os"
@ -15,6 +16,8 @@ type fileList struct {
// load all templates found as childs of the path
func LoadTemplates(path string) (*template.Template, error) {
// TODO add better check for template directory
if path == "" { return nil, errors.New("template path empty") }
f := &fileList{len(path), &template.Template{}}
err := filepath.Walk(path, f.scanFile)