File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 11Package renderer
22==================
33[ ![ Build Status] ( https://travis-ci.org/thedevsaddam/renderer.svg?branch=master )] ( https://travis-ci.org/thedevsaddam/renderer )
4- [ ![ Project status] ( https://img.shields.io/badge/version-1.1 -green.svg )] ( https://github.com/thedevsaddam/renderer/releases )
4+ [ ![ Project status] ( https://img.shields.io/badge/version-1.2 -green.svg )] ( https://github.com/thedevsaddam/renderer/releases )
55[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/thedevsaddam/renderer )] ( https://goreportcard.com/report/github.com/thedevsaddam/renderer )
66[ ![ Coverage Status] ( https://coveralls.io/repos/github/thedevsaddam/renderer/badge.svg?branch=master )] ( https://coveralls.io/github/thedevsaddam/renderer?branch=master )
77[ ![ GoDoc] ( https://godoc.org/github.com/thedevsaddam/renderer?status.svg )] ( https://godoc.org/github.com/thedevsaddam/renderer )
Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ import (
1717 "html/template"
1818 "io"
1919 "io/ioutil"
20+ "log"
2021 "net/http"
22+ "os"
2123 "path/filepath"
2224 "strings"
2325
@@ -562,5 +564,23 @@ func (r *Render) parseGlob() {
562564 for _ , fm := range r .opts .FuncMap {
563565 tmpl .Funcs (fm )
564566 }
565- r .globTemplates = template .Must (tmpl .ParseGlob (r .opts .ParseGlobPattern ))
567+ if ! strings .Contains (r .opts .ParseGlobPattern , "*." ) {
568+ log .Fatal ("renderer: invalid glob pattern!" )
569+ }
570+ pf := strings .Split (r .opts .ParseGlobPattern , "*" )
571+ fPath := pf [0 ]
572+ fExt := pf [1 ]
573+ err := filepath .Walk (fPath , func (path string , info os.FileInfo , err error ) error {
574+ if strings .Contains (path , fExt ) {
575+ _ , err = tmpl .ParseFiles (path )
576+ if err != nil {
577+ log .Println (err )
578+ }
579+ }
580+ return err
581+ })
582+ if err != nil {
583+ log .Fatal (err )
584+ }
585+ r .globTemplates = tmpl
566586}
You can’t perform that action at this time.
0 commit comments