Home Download Buy Blog Forum Support

HTML Attributes

HTML Attributes

Postby agibsonsw on Wed Jul 04, 2012 1:16 am

Attached is a simple file which some might find useful. It's a list of HTML attribute-completions. You could probably configure settings so that they display automatically within start-tags; personally, I type a letter or two and press Ctrl-Space.

Being a simple list, the attributes are not tailored according to the current tag - it will offer all of them regardless of tag. I was thinking, though, that it would be possible to create or modify html_completions.py such that only appropriate attributes are offered. Not sure whether I'll pursue this at the moment though, unless someone expresses an interest.

N.B. This file is not likely to sit well with ZenCoding.
Attachments
HTMLAttributeNames.zip
(1.18 KiB) Downloaded 276 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby agibsonsw on Wed Jul 04, 2012 8:15 pm

A slight update, in that I've added HTML5 attributes.

It's at my GitHub as well, in an HTML folder. This folder also includes HTML completions with HTML5 tags added.

[I'm considering revised the HTML tags to include an extra Tab position within the opening tag. I might do this for tags that frequently have attributes added - DIV, SPAN, etc. - or maybe to all of them.]
Attachments
HTMLAttributeNames.zip
(1.25 KiB) Downloaded 166 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby agibsonsw on Wed Jul 04, 2012 9:29 pm

Sorry, one last update - I promise :D

Some attributes are specific to a particular tag, so it makes sense to indicate this as part of the completion-description.
Attachments
HTMLAttributeNames.zip
(1.41 KiB) Downloaded 191 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby agibsonsw on Thu Jul 05, 2012 7:48 pm

I needed a further update as I omitted a few HTML5 attributes - e.g. itemprop, etc.

For a limited few of the attributes it will auto-complete values. For example, with the align attribute you can type just 'l' for 'left', 'r' for 'right' etc..

Note: I renamed the file as well.

The HTML completion files at my GitHub are modifications of the standard files:
Added HTML5 tags;
A few of the tags include attributes which I would consider non-optional. E.g. method, action for 'form', and width, height for canvas;
The form tag, method attribute, has auto-completion for the words 'get' and 'post' (just type 'g' or 'p');
Similarly, the type attribute for input will autocomplete - c for checkbox, d for date, etc..

Of course, if you replace the standard HTML completion files with these, it is possible they will be over-ridden by a future ST upgrade or new build.
Attachments
HTMLAttributes.zip
(1.72 KiB) Downloaded 156 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby agibsonsw on Fri Jul 06, 2012 10:51 pm

I welcome your opinion on the following regarding HTML tag completions:

Would it not be preferable for the Tab position to be at the end of the tag-name, rather than within the content?
<table|></table> rather than <table>|</table>.

I don't think it's worth having two tab-positions as it is simpler just to use the right-arrow to move into the content.

Alternatively, I could position the cursor like this (after the tag-name) for most major tags, but leave as is for things like 'p', 'li', 'h1', etc. tags? But wouldn't you find this disorientating?

A third option is to leave it exactly as it is now..

This is probably a small issue but I welcome opinions :)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby agibsonsw on Sun Jul 08, 2012 11:08 pm

I added just a few more HTML5 attributes, such as autocomplete and form.

The form attribute is interesting in that it enables a form control to appear outside of the form element and yet still have the control-data submitted. It may even be possible to cross-reference the value of the control in another form. However, I understand that it is supported by modern browsers - except IE10 :shock:. This negates its usefulness.

I realise that there are still a number attributes that are listed at W3C, but current support for them is minimal (or non-existent). Besides which, the spec seems to be a moving target. I suppose the advise remains to check support for any HTML5 attributes.
Attachments
HTMLAttributes (2).zip
(1.83 KiB) Downloaded 176 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby agibsonsw on Wed Jul 11, 2012 6:57 pm

I've done a little more work on this file. Where there are fixed values that an attribute can take they will autocomplete. For example, 'contenteditable' will accept 't' for 'true', 'f' for 'false' or 'i' for 'inherit'.

I've supplied two alternative for a number of boolean values. For example, either

SELECTED, or
selected="selected"

I tend to prefer all lowercase but I've taken some guidance from this useful style guide. I also like the idea of placing these boolean values at the end of the attribute list.

I've update my GitHub as well.
Attachments
HTMLAttributes (3).zip
(2.35 KiB) Downloaded 165 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby agibsonsw on Mon Jul 16, 2012 6:39 pm

There is a minor addition in the attached version. When using the atttibute type it suggests "text" but we can over-type with "b" for "button" "te" for "textarea", "c" for "checkbox", etc. [A cool aspect of this is that if you Backspace and re-enter the letter(s) it will re-instate the chosen type 8-) ]

I haven't included text/css or text/javascript as I usually enter these with the default tag-completion or a snippet (for script/link).
(Besides, there are too many t's :) ). Any types (other than for input) can just be typed in full.

Andy.
Attachments
HTMLAttributes (3a).zip
(2.54 KiB) Downloaded 271 times
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: HTML Attributes

Postby bistory on Tue Jul 17, 2012 10:30 am

Thanks for this plugin, it works fine !
Did you consider sending it to http://wbond.net/sublime_packages/community ?
bistory
 
Posts: 1
Joined: Tue Jul 17, 2012 10:28 am

Re: HTML Attributes

Postby agibsonsw on Tue Jul 17, 2012 11:01 am

bistory wrote:Thanks for this plugin, it works fine !
Did you consider sending it to http://wbond.net/sublime_packages/community ?


Thank you for your response! I could move it to Packages. There are a few steps involved, the first of which is to move it to its own repository in GitHub.

If one or two more people confirmed that it was useful to them then this might give me more encouragement ;)

My GitHub also contains updated/ expanded HTML tag-completions, but I won't include these are they will be over-written by, or conflict with, the default HTML completions. These have to be installed separately, and the default completions moved out of your Packages directory.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot] and 13 guests