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 1
1
Package renderer
2
2
==================
3
3
[ ![ 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 )
5
5
[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/thedevsaddam/renderer )] ( https://goreportcard.com/report/github.com/thedevsaddam/renderer )
6
6
[ ![ Coverage Status] ( https://coveralls.io/repos/github/thedevsaddam/renderer/badge.svg?branch=master )] ( https://coveralls.io/github/thedevsaddam/renderer?branch=master )
7
7
[ ![ 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 (
17
17
"html/template"
18
18
"io"
19
19
"io/ioutil"
20
+ "log"
20
21
"net/http"
22
+ "os"
21
23
"path/filepath"
22
24
"strings"
23
25
@@ -562,5 +564,23 @@ func (r *Render) parseGlob() {
562
564
for _ , fm := range r .opts .FuncMap {
563
565
tmpl .Funcs (fm )
564
566
}
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
566
586
}
You can’t perform that action at this time.
0 commit comments