Ejemplo n.º 1
0
def make_css_class(obj, suffix=""):
    name = utils.camel_to_hyphen(
        re.sub(r'(?i)widget|field|ginger|form|input', '',
               obj.__class__.__name__, 1))
    if suffix:
        name = "%s%s" % (name, suffix)
    return name
Ejemplo n.º 2
0
def field_to_html(field, kwargs):
    if field.is_hidden:
        return str(field)
    layout = kwargs.pop("template", None) or "default"
    process = lambda a: gutils.camel_to_hyphen(
        re.sub(r'widget|field', '', a.__class__.__name__)).lower()
    field_class_name = process(field.field)
    widget = field.field.widget
    widget_class_name = process(widget)
    template_name = "fields/%s.html" % field_class_name.replace("-", "_")
    field_name = field.name
    is_valid = not field.errors
    context = {
        'is_valid': is_valid,
        'field_errors': format_errors(field.errors),
        'field': field,
        'field_name': field_name,
        'field_class': field_class_name,
        'widget': widget,
        'widget_class': widget_class_name,
        'prefix': "",
    }
    template = [template_name, "ginger/fields/%s.html" % layout]
    html = render_to_string(template, context)
    return html
Ejemplo n.º 3
0
def field_to_html(field, kwargs):
    if field.is_hidden:
        return str(field)
    layout = kwargs.pop("template", None) or "default"
    process = lambda a: gutils.camel_to_hyphen(re.sub( r'widget|field', '',a.__class__.__name__)).lower()
    field_class_name = process(field.field)
    widget = field.field.widget
    widget_class_name = process(widget)
    template_name = "fields/%s.html"%field_class_name.replace("-", "_")
    field_name = field.name
    is_valid = not field.errors
    context = {
        'is_valid': is_valid,
        'field_errors': format_errors(field.errors),
        'field': field,
        'field_name': field_name,
        'field_class': field_class_name,
        'widget': widget,
        'widget_class': widget_class_name,
        'prefix': "",
    }
    template = [template_name, "ginger/fields/%s.html"%layout]
    html = render_to_string(template, context)
    return html
Ejemplo n.º 4
0
def make_class_name(obj):
    return gutils.camel_to_hyphen(re.sub(r'widget|field|ginger', '',obj.__class__.__name__)).lower()
Ejemplo n.º 5
0
def make_class_name(obj):
    return gutils.camel_to_hyphen(
        re.sub(r'widget|field|ginger', '', obj.__class__.__name__)).lower()
Ejemplo n.º 6
0
def make_css_class(obj, suffix=""):
    name = utils.camel_to_hyphen(re.sub(r'(?i)widget|field|ginger|form|input', '', obj.__class__.__name__, 1))
    if suffix:
        name = "%s%s" % (name, suffix)
    return name