Merge pull request #109 from moul/dev/moul/escaped-paths
feat: support escaped paths (#107)
This commit is contained in:
commit
0a47157c26
10
encoder.go
10
encoder.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"log"
|
"log"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -94,6 +95,7 @@ func (e *GenericTemplateBasedEncoder) templates() ([]string, error) {
|
|||||||
if e.debug {
|
if e.debug {
|
||||||
log.Printf("new template: %q", rel)
|
log.Printf("new template: %q", rel)
|
||||||
}
|
}
|
||||||
|
|
||||||
filenames = append(filenames, rel)
|
filenames = append(filenames, rel)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -135,6 +137,14 @@ func (e *GenericTemplateBasedEncoder) genAst(templateFilename string) (*Ast, err
|
|||||||
Enum: e.enum,
|
Enum: e.enum,
|
||||||
}
|
}
|
||||||
buffer := new(bytes.Buffer)
|
buffer := new(bytes.Buffer)
|
||||||
|
|
||||||
|
unescaped, err := url.QueryUnescape(templateFilename)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("failed to unescape filepath %q: %v", templateFilename, err)
|
||||||
|
} else {
|
||||||
|
templateFilename = unescaped
|
||||||
|
}
|
||||||
|
|
||||||
tmpl, err := template.New("").Funcs(pgghelpers.ProtoHelpersFuncMap).Parse(templateFilename)
|
tmpl, err := template.New("").Funcs(pgghelpers.ProtoHelpersFuncMap).Parse(templateFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user