LESS Pre-processing and null arguments?

This can be difficult to explain. Is there a way to less write out the @child argument without overloading the mix-in? I really don't want two mixes. If I use "", double quotes are output. I would like the LESS compiler to leave it blank.

LESS CODE

.build-on(size, @child) 
{
    &--1-1 @{child}
    {             
        width: 100%;
    }

    &--1-2 @{child}
    {
        width: 50.0%;
    }

    &--1-3 @{child}
    {
        width: 33.3%;
    }

    &--1-4 @{child}
    {
        width: 25.0%;
    }

    &--1-5 @{child}
    {
        width: 20.0%;
    }
}

// I might need to provide a child element

.data-table
{
    .build-on(size, table);
}

// I might not

.grid
{
    .build-on(size, "");
}

      

+3


source to share


1 answer


Pass it like this:

.yourClass
{
    .build-on(size, ~'');
}

      

Or better yet ...



Define a default: .build-on(size, @child: ~'') { ... }

then no second second is needed:

.yourClass
{
    .build-on(size);
}

      

+3


source







All Articles