npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-myless

v0.0.41

Published

grunt-myless is a second development plugin based on grunt-contrib-less and less 1.7.5 . fixed the bug that the grunt-contrib-less can not resolve image path corretly when the less file was imported by another less file. extend less supported functions

Downloads

15

Readme

grunt-myless

grunt-myless is a second development plugin based on grunt-contrib-less and less 1.7.5 . fixed the bug that the grunt-contrib-less can not resolve image path corretly when the less file was imported by another less file. extend less supported functions and enable user to extend less function by create file at project_root_path/myless/functions. extend less grammer to let less support multiline string.

works before install

for mac

  • install libpng by : brew install libpng. if you don't use function png8-data-uri or png8-tbcdn-uri then you can skip this step.
  • install java jdk. if you don't use svg-to-png function then you can skip this step.
  • taobao intranet user please edit file: ~/.myless/conf.json

for windows

  • install java jdk. if you don't use svg-to-png function then you can skip this step.

how to use

  • npm install grunt-myless
  • add statement grunt.loadNpmTasks('grunt-myless'); in your Gruntfile.js
  • add config item for grunt-myless, all config item are same as less. for example:
 grunt.initConfig({
    ...
    myless: {
        options: {
            paths: './'
        },
        main: {
            files: [
                {
                    expand: true,
                    cwd:'src/',
                    src: ['**/*.less'],
                    dest: 'src/',
                    ext: '.css'
                }
            ]
        }
    },
    ...
 });

extend functions

  • {String} abs-path(String: pic-path)
  • {Number} pic-width(Sring: pic-path)
  • {Percent} pic-h-w-rate(String: pic-path)
  • {Number} pic-height(String: pic-path)
  • {String} png8-data-uri(String: png24-file-path)
  • {String} png8-tbcdn-uri(String: png24-file-path). taobao intranet only!
  • {String} tbcdn-uri(String: pic-path). taobao intranet only!
  • {String} svg-cont(String... svg_attr, String: svg_cont). generate svg data uri by input svg attribute and svg content. for example:
   backgbround: svg-cont('width=80px', 'height=80px', <<EOF
      <!-- your svg code here -->
   EOF) center cente no-repeat;
  • {String} svg-to-png(String: save-path, String...: svg-attrs, String: svg-cont). call apache batik to convert svg to png, return the absolute path of the png file. for example:
   backgbround: png8-data-uri(svg-to-png('./my-png.png', 'width=80px', 'height=80px', <<EOF
      <!-- your svg code here -->
   EOF)) center cente no-repeat;
  • {String} escape-utf8(String: utf8-str). escape utf8 charactors to "\xxxx" for example:
  div:before { content: escape-utf8('中文'); }

extend grammer

  • multiline string。 you can input multiline string in the form : <{2,}(\w+)...\1, for example :
    background-iamge: svg-cont('width=80px', 'height=80px', <<CODE_END
        <!-- you svg code here -->
    CODE_END);

    background-iamge: svg-cont('width=80px', 'height=80px', <<<EOF
        <!-- you svg code here -->
    EOF);    

how to extend less function youself.

grunt-myless will crate a folder named myless at the project root path when it run first time. the folder myless has two sub-folder: data, functions。suppose we want to extend to function: fn1 and fn2, and fn1 is a sync function then fn2 is a async function.

first wo need to create two js file at folder functions. the neme of two files were : fn1.js and asy-fn2.js。the prefix asy- means is a async function.

sencod to implements two functions as follow form.

// fn1.js content
module.exports = function(myless, param1, param2){
    var sum = parseInt(param1.value, 10) + parseInt(param2.value, 10);
    return myless.util.value.toLessNum(sum, 'px');
};

// asy-fn2.js content
module.exports = function(myless, done, param1, param2){
    var sum = parseInt(param1.value, 10) + parseInt(param2.value, 10);
    setTimeout(function(){
        if(sum <= 0){
            var err = 'wrong param!';
            done(err, null);
        }else{
            var ret = myless.util.value.toLessNum(sum, 'px');
            done(null, ret);
        }
    }, 1000);
};

third use functions at you less file, for example:

div {
    width : fn1(10, 20);
    height: fn2(20, 20);    
}

next works

  • try to extend less grammer to let it support if statement.
  • try to extend less grammer to let it support loop statement.
  • restruct grunt-myless based on less 2.5