Emmet - Accelerating the front end development

29

description

Links: Documentation: http://docs.emmet.io/ Emmet for Sublime Texr 2: https://github.com/sergeche/emmet-sublime#available-actions Emmet Cheat Sheet: http://docs.emmet.io/cheat-sheet/

Transcript of Emmet - Accelerating the front end development

Page 1: Emmet - Accelerating the front end development
Page 2: Emmet - Accelerating the front end development
Page 3: Emmet - Accelerating the front end development

Abbreviations

Here’s an example: this abbreviation#page>div.logo+ul#navigation>li*5>a{Item $}

...can be transformed into<div id="page"> <div class="logo"></div> <ul id="navigation"> <li><a href="#">Item 1</a></li> <li><a href="#">Item 2</a></li> <li><a href="#">Item 3</a></li> <li><a href="#">Item 4</a></li> <li><a href="#">Item 5</a></li> </ul></div>

Page 4: Emmet - Accelerating the front end development

Abbreviations

Syntax

Page 5: Emmet - Accelerating the front end development

Abbreviations

ID and CLASSIn CSS, you use elem#id and elem.class notation to reach the elements with specified id or class attributes. In Emmet, you can use the very same syntax to add these attributes to specified element:

div#content.left

<div id="content" class="left"> </div>

Page 6: Emmet - Accelerating the front end development

Abbreviations

Child: >You can use > operator to nest elements inside each other:

div>ul>li

...will produce<div> <ul> <li></li> </ul></div>

Page 7: Emmet - Accelerating the front end development

Abbreviations

Sibling: +Use + operator to place elements near each other, on the same level:

div+p+sec

...will output<div></div><p></p><section></section>

Page 8: Emmet - Accelerating the front end development

Abbreviations

Climb-up: ^With ^ operator, you can climb one level up the tree and change context where following elements should appear:

div+div+>p>span+em^bq

...outputs to<div></div><div> <p><span></span><em></em></p> <blockquote></blockquote></div>

Page 9: Emmet - Accelerating the front end development

Abbreviations

Multiplication: *With * operator you can define how many times element should be outputted:

ul>li*5

...outputs to<ul> <li></li> <li></li> <li></li> <li></li> <li></li></ul>

Page 10: Emmet - Accelerating the front end development

Abbreviations

Text: {}You can use curly braces to add text to element:

a{Clique aqui}

...will produce

<a href="">Click me</a>

Page 11: Emmet - Accelerating the front end development

Abbreviations

Attribute Operators

Page 12: Emmet - Accelerating the front end development

Abbreviations

Item numbering: $With multiplication * operator you can repeat elements, but with $ you can number them. Place $ operator inside element’s name, attribute’s name or attribute’s value to output current number of repeated element:

ul>li.item-$*5...outputs to<ul> <li class="item-1"></li> <li class="item-2"></li> <li class="item-3"></li> <li class="item-4"></li> <li class="item-5"></li></ul>

Page 13: Emmet - Accelerating the front end development

CSS Abbreviations

h10 ...outputs to

height: 10px;

h10+w20

...outputs to

height: 10px; width: 20px;

Page 14: Emmet - Accelerating the front end development

CSS Abbreviations

Vendor Prefixes

Page 15: Emmet - Accelerating the front end development

CSS Abbreviations

-bdrs

...will be expanded into

-webkit-border-radius: ;-moz-border-radius: ;border-radius: ;

Page 16: Emmet - Accelerating the front end development

CSS Abbreviations

Gradients

Page 17: Emmet - Accelerating the front end development

CSS Abbreviations

lg(left,#fc0 30%, red)

...will be expanded into

background-image: -webkit-gradient(linear, 0 0, 100% 0, color-stop(0.3, #fc0), to(red));background-image: -webkit-linear-gradient(left, #fc0 30%, red);background-image: -moz-linear-gradient(left, #fc0 30%, red);background-image: -o-linear-gradient(left, #fc0 30%, red);background-image: linear-gradient(left, #fc0 30%, red);

Page 18: Emmet - Accelerating the front end development

CSS Abbreviations

Fuzzy search

Page 19: Emmet - Accelerating the front end development

Actions

Occasionally you have to edit your HTML and CSS code to fix bugs and add new features.

Page 20: Emmet - Accelerating the front end development

Actions

Update Image Size

Page 21: Emmet - Accelerating the front end development

Actions

Shift + Control + iUpdate image size:

<img src="mario.png" alt="It's me, Mario!"><img src="mario.png" alt="It's me, Mario!" width="256" height="256">

.image { background:url(mario.png); }

.image { background:url(mario.png); width:256px; height:256px; }

Page 22: Emmet - Accelerating the front end development

Actions

Evaluate Math Expression

Page 23: Emmet - Accelerating the front end development

Actions

Shift + Command + yEvaluate math expression:

12-210

20*4+1090

Page 24: Emmet - Accelerating the front end development

Actions

Increment/Decrement Number

Page 25: Emmet - Accelerating the front end development

Actions

Increment/Decrement Number

Increment by 1: Ctrl+↑Decrement by 1: Ctrl+↓

Increment by 0.1: Alt+↑Decrement by 0.1: Alt+↓

Increment by 10: Alt + Option ↑ Decrement by 10: Alt + Option ↓

Page 26: Emmet - Accelerating the front end development

Customization!

snippets.jsonAdd your own or update existing snippets;

preferences.jsonChange behavior of some Emmet filters and actions;

syntaxProfiles.jsonDefine how generated HTML/XML should look.

Page 27: Emmet - Accelerating the front end development

Links

DocumentationEmmet documentation;

Emmet for Sublime Text 2Emmet plugin and keymap for Sublime Text 2;

Cheat SheetList of all Emmet abbreviations.

Page 28: Emmet - Accelerating the front end development

THE END

Questions?

Page 29: Emmet - Accelerating the front end development

Thank you!

:)