tpl: Simplify - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit 139585f84a82f08027ca72b3d3266b7f58db2883
(DIR) parent a721fbed1daf5f9046ceff5f831f9a859347bd90
(HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Wed, 23 Nov 2016 18:53:50 +0100
tpl: Simplify
Diffstat:
M tpl/template_funcs.go | 4 ++--
M tpl/template_resources.go | 2 +-
M tpl/template_resources_test.go | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
---
(DIR) diff --git a/tpl/template_funcs.go b/tpl/template_funcs.go
@@ -1593,7 +1593,7 @@ func dfault(dflt interface{}, given ...interface{}) (interface{}, error) {
// argument when the key is missing: {{ index . "key" | default "foo" }}
// The Go template will complain that we got 1 argument when we expectd 2.
- if given == nil || len(given) == 0 {
+ if len(given) == 0 {
return dflt, nil
}
if len(given) != 1 {
@@ -1922,7 +1922,7 @@ func humanize(in interface{}) (string, error) {
_, ok := in.(int) // original param was literal int value
_, err = strconv.Atoi(word) // original param was string containing an int value
- if ok == true || err == nil {
+ if ok || err == nil {
return inflect.Ordinalize(word), nil
}
return inflect.Humanize(word), nil
(DIR) diff --git a/tpl/template_resources.go b/tpl/template_resources.go
@@ -233,7 +233,7 @@ func getCSV(sep string, urlParts ...string) [][]string {
for i := 0; i <= resRetries; i++ {
c, err := resGetResource(url)
- if err == nil && false == bytes.Contains(c, []byte(sep)) {
+ if err == nil && !bytes.Contains(c, []byte(sep)) {
err = errors.New("Cannot find separator " + sep + " in CSV.")
}
(DIR) diff --git a/tpl/template_resources_test.go b/tpl/template_resources_test.go
@@ -72,7 +72,7 @@ func TestScpCache(t *testing.T) {
t.Errorf("Cache ignored but content is not nil: %s", string(c))
}
} else {
- if bytes.Compare(c, test.content) != 0 {
+ if !bytes.Equal(c, test.content) {
t.Errorf("\nExpected: %s\nActual: %s\n", string(test.content), string(c))
}
}
@@ -104,7 +104,7 @@ func TestScpGetLocal(t *testing.T) {
if err != nil {
t.Errorf("Error getting resource content: %s", err)
}
- if bytes.Compare(c, test.content) != 0 {
+ if !bytes.Equal(c, test.content) {
t.Errorf("\nExpected: %s\nActual: %s\n", string(test.content), string(c))
}
}
@@ -148,7 +148,7 @@ func TestScpGetRemote(t *testing.T) {
if err != nil {
t.Errorf("Error getting resource content: %s", err)
}
- if bytes.Compare(c, test.content) != 0 {
+ if !bytes.Equal(c, test.content) {
t.Errorf("\nNet Expected: %s\nNet Actual: %s\n", string(test.content), string(c))
}
cc, cErr := resGetCache(test.path, fs, test.ignore)
@@ -160,7 +160,7 @@ func TestScpGetRemote(t *testing.T) {
t.Errorf("Cache ignored but content is not nil: %s", string(cc))
}
} else {
- if bytes.Compare(cc, test.content) != 0 {
+ if !bytes.Equal(cc, test.content) {
t.Errorf("\nCache Expected: %s\nCache Actual: %s\n", string(test.content), string(cc))
}
}