|
|
|
@ -1,9 +1,14 @@
|
|
|
|
|
package environment
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/deis/tiller/pkg/engine"
|
|
|
|
|
"github.com/deis/tiller/pkg/hapi"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const GoTplEngine = "gotpl"
|
|
|
|
|
|
|
|
|
|
var DefaultEngine = GoTplEngine
|
|
|
|
|
|
|
|
|
|
// EngineYard maps engine names to engine implementations.
|
|
|
|
|
type EngineYard map[string]Engine
|
|
|
|
|
|
|
|
|
@ -12,6 +17,20 @@ func (y EngineYard) Get(k string) (Engine, bool) {
|
|
|
|
|
return e, ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default returns the default template engine.
|
|
|
|
|
//
|
|
|
|
|
// The default is specified by DefaultEngine.
|
|
|
|
|
//
|
|
|
|
|
// If the default template engine cannot be found, this panics.
|
|
|
|
|
func (y EngineYard) Default() Engine {
|
|
|
|
|
d, ok := y[DefaultEngine]
|
|
|
|
|
if !ok {
|
|
|
|
|
// This is a developer error!
|
|
|
|
|
panic("Default template engine does not exist")
|
|
|
|
|
}
|
|
|
|
|
return d
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Engine represents a template engine that can render templates.
|
|
|
|
|
//
|
|
|
|
|
// For some engines, "rendering" includes both compiling and executing. (Other
|
|
|
|
@ -55,5 +74,9 @@ type Environment struct {
|
|
|
|
|
|
|
|
|
|
// New returns an environment initialized with the defaults.
|
|
|
|
|
func New() *Environment {
|
|
|
|
|
return &Environment{}
|
|
|
|
|
e := engine.New()
|
|
|
|
|
var ey EngineYard = map[string]Engine{GoTplEngine: e}
|
|
|
|
|
return &Environment{
|
|
|
|
|
EngineYard: ey,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|