2016-05-30 16:08:09 +02:00
|
|
|
package jade
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Joker/jade"
|
|
|
|
"github.com/kataras/iris/config"
|
|
|
|
"github.com/kataras/iris/render/template/engine/html"
|
|
|
|
)
|
|
|
|
|
2016-05-31 10:05:42 +02:00
|
|
|
// Engine the JadeEngine
|
2016-05-30 16:08:09 +02:00
|
|
|
type Engine struct {
|
|
|
|
*html.Engine
|
|
|
|
}
|
|
|
|
|
2016-06-03 04:11:50 +02:00
|
|
|
// New creates and returns a new JadeEngine with its configs
|
2016-05-30 16:08:09 +02:00
|
|
|
func New(cfg config.Template) *Engine {
|
2016-06-05 12:39:45 +02:00
|
|
|
cfg.HTMLTemplate.Funcs = cfg.Jade.Funcs //copy the jade's funcs to the underline HTMLEngine
|
|
|
|
cfg.HTMLTemplate.LayoutFuncs = cfg.Jade.LayoutFuncs
|
2016-05-30 16:08:09 +02:00
|
|
|
underline := &Engine{Engine: html.New(cfg)}
|
|
|
|
underline.Middleware = func(relativeName string, fileContents string) (string, error) {
|
|
|
|
return jade.Parse(relativeName, fileContents)
|
|
|
|
}
|
2016-06-05 12:39:45 +02:00
|
|
|
|
2016-05-30 16:08:09 +02:00
|
|
|
return underline
|
|
|
|
}
|