aboutsummaryrefslogtreecommitdiffhomepage
path: root/compare
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-02-22 09:15:12 +0100
committerBjørn Erik Pedersen <[email protected]>2018-02-22 09:15:12 +0100
commit0602135fd44b0cfa0a51b0ec6e451ae58ac95666 (patch)
treebb045df0360b26dbacf682fa227d5d4e18d57bdc /compare
parent55bd46a633d68f62e131457631ba839d6f876a55 (diff)
downloadhugo-0602135fd44b0cfa0a51b0ec6e451ae58ac95666.tar.gz
hugo-0602135fd44b0cfa0a51b0ec6e451ae58ac95666.zip
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
Diffstat (limited to 'compare')
-rw-r--r--compare/compare.go (renamed from compare/eq.go)8
1 files changed, 8 insertions, 0 deletions
diff --git a/compare/eq.go b/compare/compare.go
index 6120c0bf2..19a5deaa2 100644
--- a/compare/eq.go
+++ b/compare/compare.go
@@ -19,3 +19,11 @@ package compare
type Eqer interface {
Eq(other interface{}) bool
}
+
+// Comparer can be used to compare two values.
+// This will be used when using the le, ge etc. operators in the templates.
+// Compare returns -1 if the given version is less than, 0 if equal and 1 if greater than
+// the running version.
+type Comparer interface {
+ Compare(other interface{}) int
+}