diff --git a/UltiSnips/django.snippets b/UltiSnips/django.snippets index 9d6ce27..eabd80f 100644 --- a/UltiSnips/django.snippets +++ b/UltiSnips/django.snippets @@ -1,238 +1,361 @@ priority -50 -# Generic Tags -snippet % -{% ${1} %}${2} +# This files will define django snippets from sublime text djaneiro +# FORMS SNIPPETS + +snippet form "Form" b +class ${1:FORMNAME}(forms.Form): + + ${2:# TODO: Define form fields here} endsnippet -snippet %% -{% ${1:tag_name} %} - ${2} -{% end$1 %} +snippet modelform "ModelForm" b +class ${1:MODELNAME}Form(forms.ModelForm): + + class Meta: + model = $1 endsnippet -snippet { -{{ ${1} }}${2} +snippet fbool "BooleanField" b +${1:FIELDNAME} = forms.BooleanField($2) endsnippet -# Template Tags - -snippet autoescape -{% autoescape ${1:off} %} - ${2} -{% endautoescape %} +snippet fchar "CharField" b +${1:FIELDNAME} = forms.CharField($2) endsnippet -snippet block -{% block ${1} %} - ${2} -{% endblock $1 %} +snippet fchoice "ChoiceField" b +${1:FIELDNAME} = forms.ChoiceField($2) endsnippet -snippet # -{# ${1:comment} #} +snippet fcombo "ComboField" b +${1:FIELDNAME} = forms.ComboField($2) endsnippet -snippet comment -{% comment %} - ${1} -{% endcomment %} +snippet fdate "DateField" b +${1:FIELDNAME} = forms.DateField($2) endsnippet -snippet cycle -{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +snippet fdatetime "DateTimeField" b +${1:FIELDNAME} = forms.DateTimeField($2) endsnippet -snippet debug -{% debug %} +snippet fdecimal "DecimalField" b +${1:FIELDNAME} = forms.DecimalField($2) endsnippet -snippet extends -{% extends "${1:base.html}" %} +snippet fmail "EmailField" b +${1:FIELDNAME} = forms.EmailField($2) endsnippet -snippet filter -{% filter ${1} %} - ${2} -{% endfilter %} +snippet ffile "FileField" b +${1:FIELDNAME} = forms.FileField($2) endsnippet -snippet firstof -{% firstof ${1} %} +snippet ffilepath "FilePathField" b +${1:FIELDNAME} = forms.FilePathField($2) endsnippet -snippet for -{% for ${1} in ${2} %} - ${3} -{% endfor %} +snippet ffloat "FloatField" b +${1:FIELDNAME} = forms.FloatField($2) endsnippet -snippet empty -{% empty %} - ${1} +snippet fip "IPAddressField" b +${1:FIELDNAME} = forms.IPAddressField($2) endsnippet -snippet if -{% if ${1} %} - ${2} -{% endif %} +snippet fimg "ImageField" b +${1:FIELDNAME} = forms.ImageField($2) endsnippet -snippet else -{% else %} - ${1} +snippet fint "IntegerField" b +${1:FIELDNAME} = forms.IntegerField($2) endsnippet -snippet ifchanged -{% ifchanged %}${1}{% endifchanged %} +snippet fmochoice "ModelChoiceField" b +${1:FIELDNAME} = forms.ModelChoiceField($2) endsnippet -snippet ifequal -{% ifequal ${1} ${2} %} - ${3} -{% endifequal %} +snippet fmomuchoice "ModelMultipleChoiceField" b +${1:FIELDNAME} = forms.ModelMultipleChoiceField($2) endsnippet -snippet ifnotequal -{% ifnotequal ${1} ${2} %} - ${3} -{% endifnotequal %} +snippet fmuval "MultiValueField" b +${1:FIELDNAME} = forms.MultiValueField($2) endsnippet -snippet include -{% include "${1}" %} +snippet fmuchoice "MultipleChoiceField" b +${1:FIELDNAME} = forms.MultipleChoiceField($2) endsnippet -snippet load -{% load ${1} %} +snippet fnullbool "NullBooleanField" b +${1:FIELDNAME} = forms.NullBooleanField($2) endsnippet -snippet now -{% now "${1:jS F Y H:i}" %} +snippet freg "RegexField" b +${1:FIELDNAME} = forms.RegexField($2) endsnippet -snippet regroup -{% regroup ${1} by ${2} as ${3} %} +snippet fslug "SlugField" b +${1:FIELDNAME} = forms.SlugField($2) endsnippet -snippet spaceless -{% spaceless %}${1}{% endspaceless %} +snippet fsdatetime "SplitDateTimeField" b +${1:FIELDNAME} = forms.SplitDateTimeField($2) endsnippet -snippet ssi -{% ssi ${1} %} +snippet ftime "TimeField" b +${1:FIELDNAME} = forms.TimeField($2) endsnippet -snippet trans -{% trans "${1:string}" %} +snippet ftchoice "TypedChoiceField" b +${1:FIELDNAME} = forms.TypedChoiceField($2) endsnippet -snippet url -{% url ${1} as ${2} %} +snippet ftmuchoice "TypedMultipleChoiceField" b +${1:FIELDNAME} = forms.TypedMultipleChoiceField($2) endsnippet -snippet widthratio -{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +snippet furl "URLField" b +${1:FIELDNAME} = forms.URLField($2) endsnippet -snippet with -{% with ${1} as ${2} %} +# MODELS SNIPPETS + +snippet model "Model" b +class ${1:MODELNAME}(models.Model): + ${0} + class Meta: + verbose_name = "$1" + verbose_name_plural = "$1s" + + def __str__(self): + return super($1, self).__str__() + endsnippet -# Template Filters +snippet modelfull "Model" b +class ${1:MODELNAME}(models.Model): + ${2:# TODO: Define fields here} -# Note: Since SnipMate can't determine which template filter you are -# expanding without the "|" character, these do not add the "|" -# character. These save a few keystrokes still. + class Meta: + verbose_name = "$1" + verbose_name_plural = "$1s" -# Note: Template tags that take no arguments are not implemented. + def __str__(self): + return super($1, self).__str__() + + def save(self): + return super($1, self).save() + + @models.permalink + def get_absolute_url(self): + return ('') + + ${3:# TODO: Define custom methods here} -snippet add -add:"${1}" endsnippet -snippet center -center:"${1}" +snippet mauto "AutoField" b +${1:FIELDNAME} = models.AutoField($2) endsnippet -snippet cut -cut:"${1}" +snippet mbigint "BigIntegerField" b +${1:FIELDNAME} = models.BigIntegerField($2) endsnippet -snippet date -date:"${1}" +snippet mbool "BooleanField" b +${1:FIELDNAME} = models.BooleanField($2) endsnippet -snippet default -default:"${1}" +snippet mchar "CharField" b +${1:FIELDNAME} = models.CharField($2, max_length=${3:50}) endsnippet -snippet defaultifnone -default_if_none:"${1}" +snippet mcoseint "CommaSeparatedIntegerField" b +${1:FIELDNAME} = models.CommaSeparatedIntegerField($2) endsnippet -snippet dictsort -dictsort:"${1}" +snippet mdate "DateField" b +${1:FIELDNAME} = models.DateField($2) endsnippet -snippet dictsortrev -dictsortreversed:"${1}" +snippet mdatetime "DateTimeField" b +${1:FIELDNAME} = models.DateTimeField($2) endsnippet -snippet divisibleby -divisibleby:"${1}" +snippet mdecimal "DecimalField" b +${1:FIELDNAME} = models.DateTimeField($2) endsnippet -snippet floatformat -floatformat:"${1}" +snippet memail "EmailField" b +${1:FIELDNAME} = models.EmailField($2) endsnippet -snippet getdigit -get_digit:"${1}" +snippet mfile "FileField" b +${1:FIELDNAME} = models.FileField($2) endsnippet -snippet join -join:"${1}" +snippet mfilepath "FilePathField" b +${1:FIELDNAME} = models.FilePathField($2) endsnippet -snippet lengthis -length_is:"${1}" +snippet mfloat "FloatField" b +${1:FIELDNAME} = models.FloatField($2) endsnippet -snippet pluralize -pluralize:"${1}" +snippet fk "ForeignKey" b +${1:FIELDNAME} = models.ForeignKey($2) endsnippet -snippet removetags -removetags:"${1}" +snippet mip "IPAddressField" b +${1:FIELDNAME} = models.IPAddressField($2) endsnippet -snippet slice -slice:"${1}" +snippet mimg "ImageField" b +${1:FIELDNAME} = models.ImageField($2) endsnippet -snippet stringformat -stringformat:"${1}" +snippet mint "IntegerField" b +${1:FIELDNAME} = models.IntegerField($2) endsnippet -snippet time -time:"${1}" +snippet m2m "ManyToManyField" b +${1:FIELDNAME} = models.ManyToManyField($2) endsnippet -snippet truncatewords -truncatewords:${1} +snippet mnullbool "NullBooleanField" b +${1:FIELDNAME} = models.NullBooleanField($2) endsnippet -snippet truncatewordshtml -truncatewords_html:${1} +snippet o2o "OneToOneField" b +${1:FIELDNAME} = models.OneToOneField($2) endsnippet -snippet urlizetrunc -urlizetrunc:${1} +snippet mphone "PhoneNumberField" b +${1:FIELDNAME} = models.PhoneNumberField($2) endsnippet -snippet wordwrap -wordwrap:${1} +snippet mposint "PositiveIntegerField" b +${1:FIELDNAME} = models.PositiveIntegerField($2) endsnippet -# vim:ft=snippets: +snippet mpossmallint "PositiveSmallIntegerField" b +${1:FIELDNAME} = models.PositiveSmallIntegerField($2) +endsnippet + +snippet mslug "SlugField" b +${1:FIELDNAME} = models.SlugField($2) +endsnippet + +snippet msmallint "SmallIntegerField" b +${1:FIELDNAME} = models.SmallIntegerField($2) +endsnippet + +snippet mtext "TextField" b +${1:FIELDNAME} = models.TextField($2) +endsnippet + +snippet mtime "TimeField" b +${1:FIELDNAME} = models.TimeField($2) +endsnippet + +snippet murl "URLField" b +${1:FIELDNAME} = models.URLField($2) +endsnippet + +snippet musstate "USStateField" b +${1:FIELDNAME} = models.USStateField($2) +endsnippet + +snippet mxml "XMLField" b +${1:FIELDNAME} = models.XMLField($2) +endsnippet + +# VIEWS SNIPPETS + +snippet adminview "Model Admin View" b +class ${1}Admin(admin.ModelAdmin): + ''' + Admin View for ${1} + ''' + list_display = ('${2}',) + list_filter = ('${3}',) + inlines = [ + ${4}Inline, + ] + raw_id_fields = ('${5}',) + readonly_fields = ('${6}',) + search_fields = ['${7}'] +admin.site.register(${1}, ${1}Admin) +endsnippet + +snippet createview "Generic Create View" b +class ${1:MODEL_NAME}CreateView(CreateView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet deleteview "Generic Delete View" b +class ${1:MODEL_NAME}DeleteView(DeleteView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet detailview "Generic Detail View" b +class ${1:MODEL_NAME}DetailView(DetailView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet listview "Generic List View" b +class ${1:MODEL_NAME}ListView(ListView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet stackedinline "Stacked Inline" b +class ${1}Inline(admin.StackedInline): + ''' + Stacked Inline View for ${1} + ''' + model = ${2:${1}} + min_num = ${3:3} + max_num = ${4:20} + extra = ${5:1} + raw_id_fields = (${6},) +endsnippet + +snippet tabularinline "Tabular Inline" b +class ${1}Inline(admin.TabularInline): + ''' + Tabular Inline View for ${1} + ''' + model = ${2:${1}} + min_num = ${3:3} + max_num = ${4:20} + extra = ${5:1} + raw_id_fields = (${6},) +endsnippet + +snippet templateview "Generic Template View" b +class ${1:CLASS_NAME}(TemplateView): + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet updateview "Generic Update View" b +class ${1:MODEL_NAME}UpdateView(UpdateView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet dispatch "Dispatch View method" b +def dispatch(self, request, *args, **kwargs): + return super(${1:CLASS_NAME}, self).dispatch(request, *args, **kwargs) +endsnippet + +snippet context "get_context_data view method" b +def get_context_data(self, **kwargs): + kwargs['extra_context'] = ${1:'New Value'} + return super(${2:CLASS_NAME}, self).get_context_data(**kwargs) +endsnippet diff --git a/UltiSnips/htmldjango.snippets b/UltiSnips/htmldjango.snippets index 5836a2f..ad57150 100644 --- a/UltiSnips/htmldjango.snippets +++ b/UltiSnips/htmldjango.snippets @@ -1,3 +1,299 @@ priority -50 -extends html, django +extends html + +# Generic Tags +snippet % "" bi +{% ${1} %}${2} +endsnippet + +snippet %% "" bi +{% ${1:tag_name} %} + ${2} +{% end$1 %} +endsnippet + +snippet { "" bi +{{ ${1} }}${2} +endsnippet + +# Template Tags + +snippet autoescape "" bi +{% autoescape ${1:off} %} + ${2} +{% endautoescape %} +endsnippet + +snippet block "" bi +{% block ${1} %} + ${2} +{% endblock $1 %} +endsnippet + +snippet # "" bi +{# ${1:comment} #} +endsnippet + +snippet comment "" bi +{% comment %} + ${1} +{% endcomment %} +endsnippet + +snippet cycle "" bi +{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +endsnippet + +snippet debug "" bi +{% debug %} +endsnippet + +snippet extends "" bi +{% extends "${1:base.html}" %} +endsnippet + +snippet filter "" bi +{% filter ${1} %} + ${2} +{% endfilter %} +endsnippet + +snippet firstof "" bi +{% firstof ${1} %} +endsnippet + +snippet for "" bi +{% for ${1} in ${2} %} + ${3} +{% endfor %} +endsnippet + +snippet empty "" bi +{% empty %} + ${1} +endsnippet + +snippet if "" bi +{% if ${1} %} + ${2} +{% endif %} +endsnippet + +snippet iif "" bi +{% if ${1} %}${2}{% endif %} +endsnippet + +snippet ielse "" bi +{% else %}${1} +endsnippet + +snippet else "" bi +{% else %} + ${1} +endsnippet + +snippet ielif "" bi +{% elif %}${1} +endsnippet + +snippet elif "" bi +{% elif %} + ${1} +endsnippet + +snippet ifchanged "" bi +{% ifchanged %}${1}{% endifchanged %} +endsnippet + +snippet ifequal "" bi +{% ifequal ${1} ${2} %} + ${3} +{% endifequal %} +endsnippet + +snippet ifnotequal "" bi +{% ifnotequal ${1} ${2} %} + ${3} +{% endifnotequal %} +endsnippet + +snippet include "" bi +{% include "${1}" %} +endsnippet + +snippet load "" bi +{% load ${1} %} +endsnippet + +snippet now "" bi +{% now "${1:jS F Y H:i}" %} +endsnippet + +snippet regroup "" bi +{% regroup ${1} by ${2} as ${3} %} +endsnippet + +snippet spaceless "" bi +{% spaceless %}${1}{% endspaceless %} +endsnippet + +snippet ssi "" bi +{% ssi ${1} %} +endsnippet + +snippet trans "" bi +{% trans "${1:string}" %} +endsnippet + +snippet url "" bi +{% url ${1} as ${2} %} +endsnippet + +snippet widthratio "" bi +{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +endsnippet + +snippet with "" bi +{% with ${1} as ${2} %} + ${VISUAL} +{% endwith %} +endsnippet + +snippet verbatim "" bi +{% verbatim %} + ${VISUAL} +{% endverbatim %} +endsnippet + +snippet super "" bi +{{ block.super }} +endsnippet + +snippet staticu "" bi +{{ STATIC_URL }} +endsnippet + +snippet static "" bi +{% static "${VISUAL}" %} +endsnippet + +snippet mediau "" bi +{{ MEDIA_URL }} +endsnippet + +snippet iblock "" bi +{% block ${1:blockname} %}${VISUAL}{% endblock $1 %} +endsnippet + +snippet csfr "" bi +{% csrf_token %} +endsnippet + +snippet blocktrans "" bi +{% blocktrans %} + ${VISUAL} +{% endblocktrans %} +endsnippet + +snippet lorem "" bi +{% lorem ${1} %} +endsnippet + +# Template Filters + +# Note: Since SnipMate can't determine which template filter you are +# expanding without the "|" character, these do not add the "|" +# character. These save a few keystrokes still. + +# Note: Template tags that take no arguments are not implemented. + +snippet add "" bi +add:"${1}" +endsnippet + +snippet center "" bi +center:"${1}" +endsnippet + +snippet cut "" bi +cut:"${1}" +endsnippet + +snippet date "" bi +date:"${1}" +endsnippet + +snippet default "" bi +default:"${1}" +endsnippet + +snippet defaultifnone "" bi +default_if_none:"${1}" +endsnippet + +snippet dictsort "" bi +dictsort:"${1}" +endsnippet + +snippet dictsortrev "" bi +dictsortreversed:"${1}" +endsnippet + +snippet divisibleby "" bi +divisibleby:"${1}" +endsnippet + +snippet floatformat "" bi +floatformat:"${1}" +endsnippet + +snippet getdigit "" bi +get_digit:"${1}" +endsnippet + +snippet join "" bi +join:"${1}" +endsnippet + +snippet lengthis "" bi +length_is:"${1}" +endsnippet + +snippet pluralize "" bi +pluralize:"${1}" +endsnippet + +snippet removetags "" bi +removetags:"${1}" +endsnippet + +snippet slice "" bi +slice:"${1}" +endsnippet + +snippet stringformat "" bi +stringformat:"${1}" +endsnippet + +snippet time "" bi +time:"${1}" +endsnippet + +snippet truncatewords "" bi +truncatewords:${1} +endsnippet + +snippet truncatewordshtml "" bi +truncatewords_html:${1} +endsnippet + +snippet urlizetrunc "" bi +urlizetrunc:${1} +endsnippet + +snippet wordwrap "" bi +wordwrap:${1} +endsnippet + +# vim:ft=snippets: