How to use the less.functions function in less

To help you get started, we’ve selected a few less examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smrq / varlessify / index.js View on Github external
var fs = require('fs');
var path = require('path');
var less = require('less');
var staticModule = require('static-module');
var through = require('through2');

var savedValue;
less.functions.functionRegistry.add('__varlessifySaveValue', function (value) {
	savedValue = value;
	return value;
});

module.exports = function (file, opts) {
	if (/\.json$/.test(file)) return through();
	var parseCache = {};
	var vars = {
		__filename: file,
		__dirname: path.dirname(file)
	};
	var sm = staticModule({
		varless: { get: varless }
	}, {vars: vars});
	return sm;
github royriojas / simpless / lib / compile-less.js View on Github external
Object.keys( userFns ).forEach( function ( name ) {
    less.functions.functionRegistry.add( name.toLowerCase(), function () {
      var res = userFns[ name ].apply( less, arguments );
      return typeOf( res ) === 'object' ? res : new less.tree.Anonymous( res );
    } );
  } );
github pokemontrades / flairhq / node_modules / grunt-contrib-less / tasks / less.js View on Github external
Object.keys(options.customFunctions).forEach(function(name) {
        less.functions.functionRegistry.add(name.toLowerCase(), function() {
          var args = [].slice.call(arguments);
          args.unshift(less);
          var res = options.customFunctions[name].apply(this, args);
            return typeof res === 'object' ? res : new less.tree.Anonymous(res);
        });
      });
    }
github UniversalViewer / universalviewer / build / theme.js View on Github external
Object.keys(options.customFunctions).forEach(function(name) {
                less.functions.functionRegistry.add(name.toLowerCase(), function() {
                    var args = [].slice.call(arguments);
                    args.unshift(less);
                    var res = options.customFunctions[name].apply(this, args);
                    return typeof res === 'object' ? res : new less.tree.Anonymous(res);
                });
            });
        }
github gruntjs / grunt-contrib-less / tasks / less.js View on Github external
Object.keys(options.customFunctions).forEach(function(name) {
        less.functions.functionRegistry.add(name.toLowerCase(), function() {
          var args = [].slice.call(arguments);
          args.unshift(less);
          var res = options.customFunctions[name].apply(this, args);
          return typeof res === 'object' ? res : new less.tree.Anonymous(res);
        });
      });
    }
github chrisekelley / coconut / node_modules / grunt-contrib-less / tasks / less.js View on Github external
Object.keys(options.customFunctions).forEach(function(name) {
        less.functions.functionRegistry.add(name.toLowerCase(), function() {
          var args = [].slice.call(arguments);
          args.unshift(less);
          var res = options.customFunctions[name].apply(this, args);
            return typeof res === 'object' ? res : new less.tree.Anonymous(res);
        });
      });
    }