Skip to content

Commit

Permalink
add_placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
dd committed May 17, 2015
1 parent c292c3a commit 9a1847b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -26,6 +26,7 @@ task list
* настройки вроде DEBUG из админки
* перезагрузка сервера из админки
* put_js преобразовывать относительные пути
* тег add_attrs добавляющий всё чтопередано атрибутами тега


---------------
Expand Down
1 change: 1 addition & 0 deletions README.rst
Expand Up @@ -11,3 +11,4 @@ requirements

* Django >= 1.5.0
* pillow >= 2.0.0
* beautifulsoup4 >= 4.3.2
16 changes: 16 additions & 0 deletions meringue/templatetags/forms_utils_new.py
Expand Up @@ -3,6 +3,8 @@
import logging
import re

from bs4 import BeautifulSoup

from django import forms
from django import template
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -89,3 +91,17 @@ def field_render(boundfield):

result = FieldRender(boundfield)
return result.render()


register = template.Library()
@register.filter
def add_placeholder(field):
"""
Устанавливает placeholder равный значению label
"""
soup = BeautifulSoup(unicode(field), 'html.parser')
for tag in soup.children:
if tag.name != 'script':
tag['placeholder'] = field.label
return mark_safe(soup.renderContents())

1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -22,6 +22,7 @@
install_requires = [
'Django>=1.5.0',
'pillow>=2.0.0',
'beautifulsoup4>=4.3.2',
],
packages = find_packages(),
include_package_data = True,
Expand Down

0 comments on commit 9a1847b

Please sign in to comment.