Пример #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
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
func getwdPath(t *testing.T) gopath.GoPath {
	return gopath.FromPath(getwd(t))
}