pombreda / zen-coding

Automatically exported from code.google.com/p/zen-coding
0 stars 0 forks source link

Expand Abbreviation - Attribute Support #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am using Textmate, but I expect this is the same for all versions...

What steps will reproduce the problem?
1. Type: a[href=/]
2. Cmd+E (to expand abbreviation)

What is the expected output? What do you see instead?
Expected: <a href="/"></a>
The above gives no output

What version of the product are you using? On what operating system?
v0.3.1, Textmate r1589, OS X 10.6.2

Original issue reported on code.google.com by j...@jaikdean.com on 24 Nov 2009 at 2:50

GoogleCodeExporter commented 9 years ago
I would like this feature too. Here is my patch that adds this functionality. 
For
example:

a[href=/]
becomes: <a href="/"></a>

img.image[src=img.gif][alt="This is the \"alternative text\""]#test
becomes: <img src="img.gif" alt="This is the "alternative text""
class="image" id="test" />

li.menu[class=active]
becomes: <li class="menu active"></li>

Note that with this patch it is also possible to use ID after classes, for 
example,
div.content#content will expand properly.

Original comment by org.yi.d...@gmail.com on 3 Dec 2009 at 2:43

Attachments:

GoogleCodeExporter commented 9 years ago
Zen Coding isn't meant to be exhaustive for the CSS syntax. From the examples 
given
it would take less key strokes to use Zen Coding in the manner it was meant. For
instance, the link example given above, if you simply use "a" as the 
abbreviation and
then expand it, you'll have the anchor tag and your text cursor will be in the 
href
attribute (I think TextMate supports that) where you can type "/" and be done. 
That's
about 3 key strokes (a, cmd+e, /) compared to the 9 your example takes before 
even
doing the expansion. Does that make sense? Your suggested way simply takes 
longer.

Original comment by angelw...@gmail.com on 21 Dec 2009 at 9:56

GoogleCodeExporter commented 9 years ago
Yes, but some people prefer to use attribute syntax and sometimes this syntax is
faster. Take this example.

ul>li*5>a[href=#][title=]

This way you don't have to manually change the 5 href attributes by yourself 
(except
your text editor has block editing or something like that). I can also start 
entering
titles for my links right away without having to type the attribute names 
manually.

Original comment by org.yi.d...@gmail.com on 22 Dec 2009 at 11:02

GoogleCodeExporter commented 9 years ago
Well you can always add the title attribute via the settings file so it's there 
for
certain link abbreviations, whether you add it to the "a" abbreviation or add a 
new
one "a:t." I've added a few new snippets for common code I use. I still don't 
see
them taking on this syntax form either. If they were to, I believe it would 
look more
like,

ul>li*5>a@href=#@title

or perhaps a query string syntax,

ul>li*5>a?href=#&title

Original comment by angelw...@gmail.com on 22 Dec 2009 at 12:47

GoogleCodeExporter commented 9 years ago
Yeah, I know that, but I think that it's more convenient to implement attribute
support than editing settings file manually.

Any style of syntax will do but I still prefer the CSS style so that it is the 
same
when you write CSS code and abbreviation.

And if I have to choose between the two examples you gave, I would prefer the 
first
one because ? and & are usually found in URLs.

Original comment by org.yi.d...@gmail.com on 22 Dec 2009 at 1:40

GoogleCodeExporter commented 9 years ago

Original comment by serge....@gmail.com on 9 Feb 2010 at 10:21