Using Code Block for Animation in LESS

Let's make a function that sets animation keyframes:

styles.less.keyframes(@name, @code) {
  @keyframes @name {@code();}
}

Let's use our function:

styles.less.keyframes(anim, {
  from {
    width: 100px;
  }
  to {
    width: 200px;
  }
});

Compilation result:

styles.css@keyframes anim {
  from {
    width: 100px;
  }
  to {
    width: 200px;
  }
}