engine.go 949 B

12345678910111213141516171819202122232425262728293031
  1. package view
  2. import (
  3. "io"
  4. )
  5. // NoLayout disables the configuration's layout for a specific execution.
  6. const NoLayout = "iris.nolayout"
  7. // returns empty if it's no layout or empty layout and empty configuration's layout.
  8. func getLayout(layout string, globalLayout string) string {
  9. if layout == NoLayout {
  10. return ""
  11. }
  12. if layout == "" && globalLayout != "" {
  13. return globalLayout
  14. }
  15. return layout
  16. }
  17. // Engine is the interface which all view engines should be implemented in order to be registered inside iris.
  18. type Engine interface {
  19. // Load should load the templates from a directory of by binary(assets/go-bindata).
  20. Load() error
  21. // ExecuteWriter should execute a template by its filename with an optional layout and bindingData.
  22. ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
  23. // Ext should return the final file extension which this view engine is responsible to render.
  24. Ext() string
  25. }