From 8efaada3af4f25fe88ac673eba5af8f687592cb7 Mon Sep 17 00:00:00 2001 From: Oliver Steele Date: Tue, 11 Jul 2017 11:36:51 -0400 Subject: [PATCH] Add FromDrop func --- drops.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drops.go b/drops.go index 5f96775..6d00b68 100644 --- a/drops.go +++ b/drops.go @@ -4,3 +4,14 @@ package liquid type Drop interface { ToLiquid() interface{} } + +// FromDrop returns returns object.ToLiquid() if object's type implement this function; +// else the object itself. +func FromDrop(object interface{}) interface{} { + switch object := object.(type) { + case Drop: + return object.ToLiquid() + default: + return object + } +}