shithub: hugo

Download patch

ref: beb423a2d9683dfc07b2f69766e17c32589d489b
parent: be82b5a94fdc35de315dbccd7bef3d4c2e3d34f5
author: bep <[email protected]>
date: Mon Mar 23 12:24:18 EDT 2015

Rename Slice to Slicestr

Fixes #990

--- a/tpl/template.go
+++ b/tpl/template.go
@@ -188,11 +188,11 @@
 	return left, right
 }
 
-// Slicing in Slice is done by specifying a half-open range with
+// Slicing in Slicestr is done by specifying a half-open range with
 // two indices, start and end. 1 and 4 creates a slice including elements 1 through 3.
 // The start and/or end indices can be omitted by setting one or both of them to -1;
 // they default to zero and the slice's length respectively
-func Slice(a interface{}, start, end int) (string, error) {
+func Slicestr(a interface{}, start, end int) (string, error) {
 	aStr, err := cast.ToStringE(a)
 	if err != nil {
 		return "", err
@@ -1338,7 +1338,7 @@
 		"lt":          Lt,
 		"le":          Le,
 		"in":          In,
-		"slice":       Slice,
+		"slicestr":    Slicestr,
 		"split":       Split,
 		"intersect":   Intersect,
 		"isSet":       IsSet,
--- a/tpl/template_test.go
+++ b/tpl/template_test.go
@@ -276,7 +276,7 @@
 	}
 }
 
-func TestSlice(t *testing.T) {
+func TestSlicestr(t *testing.T) {
 	for i, this := range []struct {
 		v1     interface{}
 		v2     int
@@ -292,7 +292,7 @@
 		{123, 1, 3, "23"},
 		{tstNoStringer{}, 0, 1, false},
 	} {
-		result, err := Slice(this.v1, this.v2, this.v3)
+		result, err := Slicestr(this.v1, this.v2, this.v3)
 
 		if b, ok := this.expect.(bool); ok && !b {
 			if err == nil {