- Author:
- bmihelac
- Posted:
- November 18, 2009
- Language:
- HTML/template
- Version:
- Not specified
- Score:
- 0 (after 0 ratings)
Helper for identifing records in views similiar to rails dom_id helper.
1 2 3 4 5 6 7 8 9 10 11 12 | from django import template
register = template.Library()
@register.filter
def dom_id(el, prefix=None):
"""
{{book|dom_id}} # book_1
{{book|dom_id:'prefix'}} # prefix_book_1
"""
return '_'.join([part for part in [prefix, el._meta.module_name, str(el.id)] if part])
|
More like this
- Bootstrap Accordian by Netplay4 5 years, 9 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 9 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 9 months ago
- Reusable form template with generic view by roldandvg 8 years, 10 months ago
- Pagination Django with Boostrap by guilegarcia 8 years, 11 months ago
Comments
For people who wonder what's RoR dom_id : it's used to generate an unique ID in HTML template. e.g.
<img id="{{ book|dom_id }}" src="..." />
#
Please login first before commenting.