format/slim.js
/**
 * Renders given parsed Emmet abbreviation as Slim, formatted according to
 * `profile` options
 * @param  {Node}    tree      Parsed Emmet abbreviation
 * @param  {Profile} profile   Output profile
 * @param  {Object}  [options] Additional formatter options
 * @return {String}
 */
Renders given parsed Emmet abbreviation as Slim, formatted according to
`profile` options
@param  {Node}    tree      Parsed Emmet abbreviation
@param  {Profile} profile   Output profile
@param  {Object}  [options] Additional formatter options
@return {String}
Renders given parsed Emmet abbreviation as Slim formatted according to ` profile ` options @param { Node } tree Parsed Emmet abbreviation @param { Profile } profile Output profile @param { Object } [ options ] Additional formatter options @return { String }
function slim(tree, profile, options) {
	options = options || {};
	const SECONDARY_ATTRS = options.attributeWrap
		&& secondaryAttrs[options.attributeWrap]
		|| secondaryAttrs.none;
	const booleanAttr = SECONDARY_ATTRS === secondaryAttrs.none
		? attr => `${attr.name}=true`
		: attr => attr.name;
	const nodeOptions = {
		open: `[NAME][PRIMARY_ATTRS]${SECONDARY_ATTRS}[SELF_CLOSE]`,
		selfClose: '/',
		attributes: {
			secondary(attrs) {
				return attrs.map(attr => attr.isBoolean
					? booleanAttr(attr)
					: `${attr.name}=${profile.quote(attr.value)}`
				).join(' ');
			}
		}
	};
	return render(tree, options.field, outNode => {
		outNode = indentFormat(outNode, profile, nodeOptions);
		outNode = updateFormatting(outNode, profile);
		if (!handlePseudoSnippet(outNode)) {
			const node = outNode.node;
			if (node.value || (!node.children.length && !node.selfClosing) ) {
				outNode.text = outNode.renderFields(formatNodeValue(node, profile));
			}
		}
		return outNode;
	});
}
function slim ( tree , profile , options ) { options = options || { } ; const SECONDARY_ATTRS = options . attributeWrap && secondaryAttrs [ options . attributeWrap ] || secondaryAttrs . none ; const booleanAttr = SECONDARY_ATTRS === secondaryAttrs . none ? attr => ` ${ attr . name } ` : attr => attr . name ; const nodeOptions = { open : ` ${ SECONDARY_ATTRS } ` , selfClose : '/' , attributes : { secondary ( attrs ) { return attrs . map ( attr => attr . isBoolean ? booleanAttr ( attr ) : ` ${ attr . name } ${ profile . quote ( attr . value ) } ` ) . join ( ' ' ) ; } } } ; return render ( tree , options . field , outNode => { outNode = indentFormat ( outNode , profile , nodeOptions ) ; outNode = updateFormatting ( outNode , profile ) ; if ( ! handlePseudoSnippet ( outNode ) ) { const node = outNode . node ; if ( node . value || ( ! node . children . length && ! node . selfClosing ) ) { outNode . text = outNode . renderFields ( formatNodeValue ( node , profile ) ) ; } } return outNode ; } ) ; }
Renders given parsed Emmet abbreviation as Slim, formatted according to
 `profile` options
 @param  {Node}    tree      Parsed Emmet abbreviation
 @param  {Profile} profile   Output profile
 @param  {Object}  [options] Additional formatter options
 @return {String}
Renders given parsed Emmet abbreviation as Slim formatted according to ` profile ` options @param { Node } tree Parsed Emmet abbreviation @param { Profile } profile Output profile @param { Object } [ options ] Additional formatter options @return { String }
// Do not generate fields for nodes with empty value and children // or if node is self-closed