<?php

function smarty_modifier_format_filter_range($range)
{
    if (!$range) {
        return '';
    }

    $convertValue = function ($value) {
        if ($value === null) {
            return 'null';
        }

        return (float) $value;
    };

    $min = null;
    $max = null;
    if ($range instanceof Range) {
        $min = $range->min();
        $max = $range->max();
    } elseif (is_array($range)) {
        $min = $range['min'];
        $max = $range['max'];
    }

    return 'data-filter-value=['.$convertValue($min).','.$convertValue($max).']';
}
