Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/juliendargelos/emmet.js

Use emmet syntax with javascript
https://github.com/juliendargelos/emmet.js

Last synced: 4 days ago
JSON representation

Use emmet syntax with javascript

Awesome Lists containing this project

README

        

# Emmet.js
Use emmet syntax with Javascript.

### Version
Beta 1

### Licence
Emmet.js is under GNU General Public License v3.0.

### Requirements
Emmet.js does not require anything.

### Installation
Just include the script in your HTML page:
```html

```
Or, using the minified version:
```html

```

### Using
Emmet.js is based on the emmet syntax so [just use it](http://docs.emmet.io/abbreviations/syntax/). **Be careful, Emmet.js does not support grouping as emmet does with parenthesises**. In these examples, Node objects are represented by their HTML syntax, but they are Node objects!

Create a div:
```javascript
var div=emmet('div');
// Returns:


```

Create one hundred div-s:
```javascript
var divs=emmet('div*100');
// Returns: [

,
,...,
]
```

Create one hundred div-s incrementing the id (works with any attribute):
```javascript
var divs=emmet('div*100#d$');
// Returns: [

,
,...,
]
```

Create one hundred div-s decrementing the id:
```javascript
var divs=emmet('div*100#d$@-');
// Returns: [

,
,...,
]
```

Create a span with text "Hello" inside a div:
```javascript
var divAndSpan=emmet('div>span{Hello}');
// Returns:

Hello

```

You can use Emmet.js from any Node in the DOM so it directly appends the element(s) inside the Node (and return the element(s) as previously):
```javascript
document.body.emmet('div');
// Appends a div in the body and returns:


```

Furthermore, you can also use Emmet.js from any NodeList to directly append the element(s) inside each Node in the NodeList:
```javascript
document.getElementsByTagName('div').emmet('span');
// Append a span inside each div of the document
```

To have a more complete documentation, just go to [docs.emmet.io](http://docs.emmet.io/abbreviations/syntax/).

### Development
Emmet.js is open to any kind of contribution :)