mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-13 22:51:08 -05:00
Add Ext action to template context (closes #844)
This commit is contained in:
parent
62622eb853
commit
3fd3feeffe
1 changed files with 8 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
@ -158,6 +159,13 @@ func (c Context) StripHTML(s string) string {
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ext returns the suffix beginning at the final dot in the final
|
||||||
|
// slash-separated element of the pathStr (or in other words, the
|
||||||
|
// file extension).
|
||||||
|
func (c Context) Ext(pathStr string) string {
|
||||||
|
return path.Ext(pathStr)
|
||||||
|
}
|
||||||
|
|
||||||
// StripExt returns the input string without the extension,
|
// StripExt returns the input string without the extension,
|
||||||
// which is the suffix starting with the final '.' character
|
// which is the suffix starting with the final '.' character
|
||||||
// but not before the final path separator ('/') character.
|
// but not before the final path separator ('/') character.
|
||||||
|
|
Loading…
Reference in a new issue