1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-26 19:24:45 +01:00

Add FromDrop func

This commit is contained in:
Oliver Steele 2017-07-11 11:36:51 -04:00
parent 55cf56e9a0
commit 8efaada3af

View File

@ -4,3 +4,14 @@ package liquid
type Drop interface { type Drop interface {
ToLiquid() 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
}
}