How to insert LESS mixin in to JavaScript code

Is there any option to insert some LESS mixin in to JS code?

I have this border-radius mixin:

.border_radius(@radius: 5px) {
  border-radius: @radius;
  -moz-border-radius: @radius;
  -webkit-border-radius: @radius;
}

So is there any possible to add this mixin in to jQuery code?

var less = require('less');

$('.circle').css({
    width: width, height: width,
    less.border_radius(10px);
});

Answers


You could define the JavaScript equivalent of the LESS mixins you require:

HTML

<div class="circle"></div>

CSS

.circle { border: 1px solid #FF0000; }

jQuery

function border_radius(radius) {
  radius = radius || '5px';
  return {
    'border-radius': radius,
    '-moz-border-radius': radius,
    '-webkit-border-radius': radius
  }
}

var styles = border_radius(),
    width = '20px';
styles.width = width;
styles.height = width;

$('.circle').css(styles);

JSFiddle


Need Your Help

How to skip the teardown section in Gallio/MbUnit from a test case

c# automated-tests watin mbunit gallio

I'm using Gallio/MbUnit with WatiN and I have a defined method to executes as TearDown, what I need is a way to skip the TearDown from a specific Test Case, is that possible?

Long Polling set_time_limit() to the max possible

php long-polling

I'm wondering how to set the max possible time limit for a php page,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.