import netaddr


def filters():
    return {
        "netmask_to_cidr": netmask_to_cidr,
        "cidr_to_netmask": cidr_to_netmask,
    }


def netmask_to_cidr(value):
    """ Converts a network mask to it's CIDR value. """
    return netaddr.IPAddress(value).netmask_bits()


def cidr_to_netmask(value):
    """ Converts a CIDR prefix-length to a network mask. """
    return netaddr.IPNetwork("1.1.1.1/{}".format(value)).netmask

@@ -161,32 +161,36 @@
 (value):%0A    %22%22%22
+%0A   
  Converts a netw
@@ -217,16 +217,95 @@
 R value.
+%0A%0A    Examples:%0A        %3E%3E%3E %22%7B%7B '255.255.255.0'%7Cnetmask_to_cidr %7D%7D%22 -%3E %2224%22%0A   
  %22%22%22%0A   
@@ -389,16 +389,20 @@
 %0A    %22%22%22
+%0A   
  Convert
@@ -442,16 +442,95 @@
 rk mask.
+%0A%0A    Examples:%0A        %3E%3E%3E %22%7B%7B '24'%7Ccidr_to_netmask %7D%7D%22 -%3E %22255.255.255.0%22%0A   
  %22%22%22%0A   

Add examples