#NEWLINE# @ register . filter #NEWLINE# def as_bootstrap_horizontal( form , label_classes = '' ) : #NEWLINE# #INDENT# template = get_template ( 'bootstrap/form.html' ) #NEWLINE# form = _preprocess_fields ( form ) #NEWLINE# if ( label_classes == '' ) : #NEWLINE# #INDENT# label_classes = 'col-md-2' #NEWLINE# #UNINDENT# css_classes = { #NEWLINE# #INDENT# 'label' : label_classes , #NEWLINE# 'single_container' : '' , #NEWLINE# 'wrap' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# for label_class in label_classes . split ( ' ' ) : #NEWLINE# #INDENT# ( split_class , column_count ) = label_class . rsplit ( '-' , 1 ) #NEWLINE# column_count = int ( column_count ) #NEWLINE# if ( column_count < 12 ) : #NEWLINE# #INDENT# offset_class = '{split_class}-offset-{column_count}' . format ( split_class = split_class , column_count = column_count ) #NEWLINE# wrap_class = '{split_class}-{column_count}' . format ( split_class = split_class , column_count = ( 12 - column_count ) ) #NEWLINE# css_classes [ 'single_container' ] += ( ( ( offset_class + ' ' ) + wrap_class ) + ' ' ) #NEWLINE# css_classes [ 'wrap' ] += ( wrap_class + ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# c = Context ( { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# 'css_classes' : css_classes , #NEWLINE# #UNINDENT# } ) #NEWLINE# return template . render ( c )