Skip to content

Commit

Permalink
Allow modifiers in className to accept array instead of list of args
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Szajna committed Jan 28, 2019
1 parent d62620e commit 86ccdf8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions generators/app/templates/gulp/templatesFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ module.exports = function templateFunctions(data = {}) {
}
const classes = [name];
let el;
for (let i = 0; i < args.length; i += 1) {
el = args[i];
let modifiers;
if(args[0] instanceof Array) {
modifiers = args[0];
} else {
modifiers = args;
}
for (let i = 0; i < modifiers.length; i += 1) {
el = modifiers[i];
if (el && typeof el === 'string') {
classes.push(`${name}--${el}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ public function className( $name = '', $modifiers = null ) {
if ( ! is_string( $name ) || empty( $name ) ) {
return '';
}
$modifiers = array_slice( func_get_args(), 1 );
if ( ! is_array( $modifiers ) ) {
$modifiers = array_slice( func_get_args(), 1 );
}
$classes = array( $name );
foreach ( $modifiers as $modifier ) {
if ( is_string( $modifier ) && ! empty( $modifier ) ) {
Expand Down

0 comments on commit 86ccdf8

Please sign in to comment.