handleExternalClasses.js 783 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. function handleExternalClasses() {
  3. var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4. var arr = opts.externalClasses || [];
  5. var _class = [];
  6. arr.forEach(function (a) {
  7. _class.push(_transform(a) || '');
  8. });
  9. opts.data = opts.data || {};
  10. opts.data.__classNames = _class;
  11. opts.data.__classes = '';
  12. function _transform() {
  13. var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  14. str = str.replace(/-(\w)/g, function () {
  15. for (var _len = arguments.length, $ = new Array(_len), _key = 0; _key < _len; _key++) {
  16. $[_key] = arguments[_key];
  17. }
  18. return $[1].toUpperCase();
  19. });
  20. return str || '';
  21. }
  22. return opts;
  23. }
  24. module.exports = handleExternalClasses;