mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Make ge, le etc. work with the Hugo Version number
This means that you can do something ala: ```html {{ if ge .Hugo.Version "0.36" }}Reasonable new Hugo version!{{ end }} ``` The intented use is feature toggling, but please note that it will take some time and Hugo versions until this can be trusted. It does not work in older Hugo versions. Fixes #4443
This commit is contained in:
@@ -21,6 +21,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -171,6 +173,13 @@ func doTestCompare(t *testing.T, tp tstCompareType, funcUnderTest func(a, b inte
|
||||
{tstEqerType1("a"), tstEqerType2("a"), 0},
|
||||
{tstEqerType2("a"), tstEqerType1("a"), 0},
|
||||
{tstEqerType2("a"), tstEqerType1("b"), -1},
|
||||
{helpers.MustParseHugoVersion("0.32.1").Version(), helpers.MustParseHugoVersion("0.32").Version(), 1},
|
||||
{helpers.MustParseHugoVersion("0.35").Version(), helpers.MustParseHugoVersion("0.32").Version(), 1},
|
||||
{helpers.MustParseHugoVersion("0.36").Version(), helpers.MustParseHugoVersion("0.36").Version(), 0},
|
||||
{helpers.MustParseHugoVersion("0.32").Version(), helpers.MustParseHugoVersion("0.36").Version(), -1},
|
||||
{helpers.MustParseHugoVersion("0.32").Version(), "0.36", -1},
|
||||
{"0.36", helpers.MustParseHugoVersion("0.32").Version(), 1},
|
||||
{"0.36", helpers.MustParseHugoVersion("0.36").Version(), 0},
|
||||
} {
|
||||
result := funcUnderTest(test.left, test.right)
|
||||
success := false
|
||||
|
Reference in New Issue
Block a user