aboutsummaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-05-13 01:47:05 +0800
committerGitHub <noreply@github.com>2021-05-12 18:47:05 +0100
commitb61092bcb04a37397ca4aece870bb829a73e8fa1 (patch)
treef3c57d445174130a0a4e50d6325f84387d379338 /vendor
parentec2addc0ed5f20bedf904acf05f04520cc0ed23b (diff)
downloadgitea-b61092bcb04a37397ca4aece870bb829a73e8fa1.tar.gz
gitea-b61092bcb04a37397ca4aece870bb829a73e8fa1.zip
Upgrade unrolled/render to v1.1.1 (#15845)
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/unrolled/render/render.go27
-rw-r--r--vendor/modules.txt2
2 files changed, 19 insertions, 10 deletions
diff --git a/vendor/github.com/unrolled/render/render.go b/vendor/github.com/unrolled/render/render.go
index 4cd11cdfcc..ad2e77ee19 100644
--- a/vendor/github.com/unrolled/render/render.go
+++ b/vendor/github.com/unrolled/render/render.go
@@ -123,7 +123,7 @@ type Render struct {
// Customize Secure with an Options struct.
opt Options
templates *template.Template
- templatesLk sync.Mutex
+ templatesLk sync.RWMutex
compiledCharset string
}
@@ -196,8 +196,8 @@ func (r *Render) compileTemplates() {
func (r *Render) compileTemplatesFromDir() {
dir := r.opt.Directory
- r.templates = template.New(dir)
- r.templates.Delims(r.opt.Delims.Left, r.opt.Delims.Right)
+ tmpTemplates := template.New(dir)
+ tmpTemplates.Delims(r.opt.Delims.Left, r.opt.Delims.Right)
// Walk the supplied directory and compile any files that match our extension list.
r.opt.FileSystem.Walk(dir, func(path string, info os.FileInfo, err error) error {
@@ -227,7 +227,7 @@ func (r *Render) compileTemplatesFromDir() {
}
name := (rel[0 : len(rel)-len(ext)])
- tmpl := r.templates.New(filepath.ToSlash(name))
+ tmpl := tmpTemplates.New(filepath.ToSlash(name))
// Add our funcmaps.
for _, funcs := range r.opt.Funcs {
@@ -241,12 +241,16 @@ func (r *Render) compileTemplatesFromDir() {
}
return nil
})
+
+ r.templatesLk.Lock()
+ r.templates = tmpTemplates
+ r.templatesLk.Unlock()
}
func (r *Render) compileTemplatesFromAsset() {
dir := r.opt.Directory
- r.templates = template.New(dir)
- r.templates.Delims(r.opt.Delims.Left, r.opt.Delims.Right)
+ tmpTemplates := template.New(dir)
+ tmpTemplates.Delims(r.opt.Delims.Left, r.opt.Delims.Right)
for _, path := range r.opt.AssetNames() {
if !strings.HasPrefix(path, dir) {
@@ -272,7 +276,7 @@ func (r *Render) compileTemplatesFromAsset() {
}
name := (rel[0 : len(rel)-len(ext)])
- tmpl := r.templates.New(filepath.ToSlash(name))
+ tmpl := tmpTemplates.New(filepath.ToSlash(name))
// Add our funcmaps.
for _, funcs := range r.opt.Funcs {
@@ -285,6 +289,10 @@ func (r *Render) compileTemplatesFromAsset() {
}
}
}
+
+ r.templatesLk.Lock()
+ r.templates = tmpTemplates
+ r.templatesLk.Unlock()
}
// TemplateLookup is a wrapper around template.Lookup and returns
@@ -389,14 +397,15 @@ func (r *Render) Data(w io.Writer, status int, v []byte) error {
// HTML builds up the response from the specified template and bindings.
func (r *Render) HTML(w io.Writer, status int, name string, binding interface{}, htmlOpt ...HTMLOptions) error {
- r.templatesLk.Lock()
- defer r.templatesLk.Unlock()
// If we are in development mode, recompile the templates on every HTML request.
if r.opt.IsDevelopment {
r.compileTemplates()
}
+ r.templatesLk.RLock()
+ defer r.templatesLk.RUnlock()
+
opt := r.prepareHTMLOptions(htmlOpt)
if tpl := r.templates.Lookup(name); tpl != nil {
if len(opt.Layout) > 0 {
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 656676e88a..5bd9c1ba5e 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -743,7 +743,7 @@ github.com/unknwon/i18n
# github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae
## explicit
github.com/unknwon/paginater
-# github.com/unrolled/render v1.1.0
+# github.com/unrolled/render v1.1.1
## explicit
github.com/unrolled/render
# github.com/urfave/cli v1.22.5