示例#1
0
文件: gone.go 项目: fxnn/gone
func contentRoot() gopath.GoPath {
	if wd, err := os.Getwd(); err == nil {
		return gopath.FromPath(wd)
	} else {
		panic(err)
	}
}
示例#2
0
文件: static_test.go 项目: fxnn/gone
func TestExportTemplates(t *testing.T) {
	var wd, _ = os.Getwd()
	var sut = NewStaticLoader()
	var targetPath = gopath.FromPath(wd).JoinPath("gone_test")
	defer os.RemoveAll(targetPath.Path())
	var err = sut.WriteAllTemplates(targetPath)
	if err != nil {
		t.Fatalf("Couldn't write templates: %v", err)
	}
}
示例#3
0
文件: gone.go 项目: fxnn/gone
func templatePath(contentRoot gopath.GoPath, cfg config.Config) (result gopath.GoPath) {
	// configuration
	result = gopath.FromPath(cfg.TemplatePath)
	if !result.IsEmpty() {
		if !result.IsDirectory() {
			log.Fatalf("configured template path is no directory: %s", result.Path())
		}
		log.Printf("using templates from %s (by configuration)", result.Path())
		return result
	}

	// convention
	result = contentRoot.JoinPath(defaultTemplateDirectoryName)
	if result.IsDirectory() {
		log.Printf("using templates from %s (by convention)", result.Path())
		return result
	}

	// default
	log.Printf("using default templates")
	return gopath.Empty()
}
示例#4
0
文件: utils_test.go 项目: fxnn/gone
func getwdPath(t *testing.T) gopath.GoPath {
	return gopath.FromPath(getwd(t))
}