Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

Custom JSX attribute generation #2

Merged
merged 4 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions format/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ function formatAttributes(outNode, profile) {
attrValue = outNode.renderFields(attr.value);
}

return ` ${attrName}=${profile.quote(attrValue)}`;
return attr.options.before && attr.options.after
? ` ${attrName}=${attr.options.before+attrValue+attr.options.after}`
: ` ${attrName}=${profile.quote(attrValue)}`;
}).join('');
}

Expand Down Expand Up @@ -313,4 +315,4 @@ function getFormatOptions(options) {
const format = Object.assign({}, options && options.format);
format.comment = Object.assign({}, commentOptions, format.comment);
return format;
}
}
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ describe('Main formatter', () => {
assert.equal(expand('a>b', 'html'), '<a><b></b></a>');
assert.equal(expand('a>b', 'slim'), 'a\n\tb');
assert.equal(expand('a>b', 'haml'), '%a\n\t%b');
assert.equal(expand('a[foo={bar}]>b[foo=foo]', 'html'), '<a foo={bar}><b foo="foo"></b></a>');
});
});