Package omeroweb :: Package webgateway :: Package templatetags :: Module common_filters
[hide private]
[frames] | no frames]

Module common_filters

source code

Functions [hide private]
 
hash(value, key) source code
 
ago(value)
Formats a datetime.datetime object as time Ago.
source code
 
truncateafter(value, arg)
Truncates a string after a given number of chars Argument: Number of chars to truncate after
source code
 
truncatebefor(value, arg)
Truncates a string after a given number of chars Argument: Number of chars to truncate befor
source code
 
shortening(value, arg) source code
 
subtract(value, arg)
Subtracts the arg from the value
source code
 
get_range(value)
Filter - returns a list containing range made from given value Usage (in template):
source code
Variables [hide private]
  register = template.Library()
  logger = logging.getLogger(__name__)

Imports: datetime, traceback, logging, settings, template


Function Details [hide private]

hash(value, key)

source code 
Decorators:
  • @register.filter

ago(value)

source code 

Formats a datetime.datetime object as time Ago. E.g. '3 days 2 hours 10 minutes'

Decorators:
  • @register.filter

truncateafter(value, arg)

source code 

Truncates a string after a given number of chars Argument: Number of chars to truncate after

Decorators:
  • @register.filter

truncatebefor(value, arg)

source code 

Truncates a string after a given number of chars Argument: Number of chars to truncate befor

Decorators:
  • @register.filter

shortening(value, arg)

source code 
Decorators:
  • @register.filter

subtract(value, arg)

source code 

Subtracts the arg from the value

Decorators:
  • @register.filter

get_range(value)

source code 

Filter - returns a list containing range made from given value
Usage (in template):

<ul>{% for i in 3|get_range %}
  <li>{{ i }}. Do something</li>
{% endfor %}</ul>

Results with the HTML:
<ul>
  <li>0. Do something</li>
  <li>1. Do something</li>
  <li>2. Do something</li>
</ul>

Instead of 3 one may use the variable set in the views

Decorators:
  • @register.filter