view.go 957 B

12345678910111213141516171819202122
  1. package context
  2. import "io"
  3. // ViewEngine is the interface which all view engines should be implemented in order to be registered inside iris.
  4. type ViewEngine interface {
  5. // Load should load the templates from a physical system directory or by an embedded one (assets/go-bindata).
  6. Load() error
  7. // ExecuteWriter should execute a template by its filename with an optional layout and bindingData.
  8. ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error
  9. // Ext should return the final file extension which this view engine is responsible to render.
  10. Ext() string
  11. }
  12. // ViewEngineFuncer is an addition of a view engine,
  13. // if a view engine implements that interface
  14. // then iris can add some closed-relative iris functions
  15. // like {{ url }}, {{ urlpath }} and {{ tr }}.
  16. type ViewEngineFuncer interface {
  17. // AddFunc should adds a function to the template's function map.
  18. AddFunc(funcName string, funcBody interface{})
  19. }