import emel from "emel";// or const emel = require("emel"); // for cjs// or const emel = global.emel; // for umdconst emmetString = "table>thead>tr>th{col1}+th{col2}^^tbody>(tr>td[colspan=2]{2 col width})+tr>td.col${1 col width}*2";const options = {};const element = emel(emmetString, options);/** * TABLE DOM element: * <table> * <thead> * <tr> * <th>col1</th> * <th>col2</th> * </tr> * </thead> * <tbody> * <tr> * <td colspan="2">2 col width</td> * </tr> * <tr> * <td class="col1">1 col width</td> * <td class="col2">1 col width</td> * </tr>
Setting default options
You can set the default options by creating a new instance of emel and pass the default options.
import Emel from "emel";// or const Emel = require("emel"); // for cjs// or const Emel = global.emel; // for umdconst { emel } = new Emel({placeholders: [1, 2]});const element = emel("div{?}+div{?}");/** * <div>1</div> * <div>2</div> */
Doc
Default to browser document.
For Angular SSR, use injector.get(DOCUMENT)
import { DOCUMENT } from '@angular/common';emel(`div>p*3`, { doc: injector.get(DOCUMENT)});
ReturnSingleChild
By default emel will always return the elements as children of a document fragment.
If you set the returnSingleChild option to true it will only wrap the elements in a document fragment if there are multiple top level elements.
Multiline
By default space characters are not allowed outside of text nodes.
If you want to write readable strings with multiple lines you can use the multiline option to remove newline characters and surrounding spaces.