Custom tags and filters for Django's HTML templating.
Surprisingly, Django's templating does not provide some basic functionality I expected to be there. So, I had to write some custom tags (like the sum of a list) and filters specific to LyProX's needs.
| Class | |
Custom math extension for markdown. |
| Function | barplot |
Return the relative width to be sent to the CSS for the dashboard's bar plot. |
| Function | capitalize |
Capitalize the subsite name. |
| Function | concat |
Concatenate this & other. |
| Function | custom |
Render custom markdown with footnotes and tables. |
| Function | get |
Get an item from dict-like mapping using key. |
| Function | get |
Get the logo of the institution providing a dataset. |
| Function | get |
Get the percentage value_counts[key] in the total of value_counts. |
| Function | get |
Get the subsite name from the dataset name. |
| Function | getattr_ |
Get an attribute from instance using attr. |
| Function | include |
Include a markdown file in the template. |
| Function | index |
Get the i-th element of seq. |
| Function | multiply |
Multiply value by factor. |
| Function | remove |
Remove host from url. So, https://foo.com/bar/baz becomes bar/baz. |
| Function | render |
Format and render raw JSON text. |
| Function | render |
Render raw markdown text. |
| Function | render |
Format and render raw YAML text. |
| Function | safe |
Safely evaluate an expression. |
| Function | sum_ |
Implement the sum im Django templates. |
| Function | to |
Convert arguments to a list. |
| Type Variable | KT |
Undocumented |
| Type Variable | N |
Undocumented |
| Type Variable | T |
Undocumented |
| Type Variable | VT |
Undocumented |
| Variable | logger |
Undocumented |
| Variable | register |
Undocumented |
dict[ Any, int], argstr: str) -> float:
¶
Return the relative width to be sent to the CSS for the dashboard's bar plot.
Use it like this in the HTML templates: {{ value_counts|barplot_css:'<key>,<width>' }}, where the key and the total width are separated by a comma. The key is the key of the value in the value_counts dict and the width is the total width of the bar plot.
dict[ Any, int], key: Any) -> str:
¶
Get the percentage value_counts[key] in the total of value_counts.
Use it like this in the HTML templates: {{ value_counts|get_percent:key }}.
template.RequestContext, template_name: str) -> str:
¶
Include a markdown file in the template.
The markdown file may also include Django template tags, just as the HTML. This tag is used like this: {% include_md "path/to/file.md" %}.
Implement the sum im Django templates.
Use it like this: {{ mylist|sum }} or {{ mydict.values|sum }}.