Skip to content

Commit

Permalink
Merge pull request #16 from Fenny/master
Browse files Browse the repository at this point in the history
Fix pug reload
  • Loading branch information
Fenny committed Jun 17, 2020
2 parents 0f18c04 + b7bac4d commit 18b4542
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func main() {
// and template extension using <engine>.New(dir, ext string)
engine := html.New("./views", ".html")

// We also support the http.FileSystem interface
// See examples below to load templates from embedded files
engine := html.NewFileSystem(http.Dir("./views"), ".html")

// Reload the templates on each render, good for development
engine.Reload(true) // Optional. Default: false

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/cbroglie/mustache v1.1.0
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385
github.com/flosch/pongo2 v0.0.0-20200518135938-dfb43dbdc22a
github.com/mattn/go-slim v0.0.0-20190926010428-236f1c35e4e6
github.com/valyala/bytebufferpool v1.0.0
github.com/yosssi/ace v0.0.5
gopkg.in/yaml.v2 v2.3.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4slttB4vD+b9btVEnWgL3Q00OBTzVT8B9C0c=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
github.com/CloudyKit/jet v2.1.2+incompatible h1:ybZoYzMBdoijK6I+Ke3vg9GZsmlKo/ZhKdNMWz0P26c=
github.com/CloudyKit/jet v2.1.2+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w=
github.com/CloudyKit/jet/v3 v3.0.0 h1:1PwO5w5VCtlUUl+KTOBsTGZlhjWkcybsGaAau52tOy8=
github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo=
github.com/Joker/hpp v0.0.0-20180418125244-6893e659854a h1:PiDAizhfJbwZMISZ1Itx1ZTFeOFCml89Ofmz3V8rhoU=
Expand Down Expand Up @@ -41,6 +43,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-slim v0.0.0-20190926010428-236f1c35e4e6 h1:GF43XHtQ/ewS07mITQZyi9gXhWZ7x7crGWp2hvHUEkM=
github.com/mattn/go-slim v0.0.0-20190926010428-236f1c35e4e6/go.mod h1:ma9TUJeni8LGZMJvOwbAv/FOwiwqIMQN570LnpqCBSM=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
Expand Down
3 changes: 2 additions & 1 deletion pug/pug.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func New(directory, extension string) *Engine {
extension: extension,
layout: "embed",
funcmap: make(map[string]interface{}),
Templates: template.New(directory),
}
engine.AddFunc(engine.layout, func() error {
return fmt.Errorf("layout called unexpectedly.")
Expand Down Expand Up @@ -124,6 +123,8 @@ func (e *Engine) Load() error {
e.mutex.Lock()
defer e.mutex.Unlock()

e.Templates = template.New(e.directory)

// Set template settings
e.Templates.Delims(e.left, e.right)
e.Templates.Funcs(e.funcmap)
Expand Down

0 comments on commit 18b4542

Please sign in to comment.