how to use less mixins file in my code?

complez

here is my code

var parser = window.less.Parser();
        try{
            parser.parse(aztp_css_editor.getValue(), function(error, result){
                if(!error){
                    alert(result.toCSS());
                }else{
                    alert(error);
                }
            });
        }catch(error){
            alert(error);
        }

I have a mixins less file here http://lessprefixer.com/ for shorthand css3 prefix, how I setup it into my parse less code?

Bass Jobsen

I think you should better the less.render function, see also: http://lesscss.org/usage/#programmatic-usage.

But indeed you can use the @import directive as already made clear by @seven-phases-max.

Example:

<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.1.0/less.min.js"></script>
<script>
less.render('@import "test.less"; p {color: @red; }', {'include-path': 'test/'})
    .then(function(output) {
        // output.css = string of css
        // output.map = string of sourcemap
        // output.imports = array of string filenames of the imports referenced
        console.log(output.css);
    },
    function(error) {
    });
</script> 

The above compiles well (results in output.css) when test.less is available in the same path as the html which contains the code. You can also use a path in your import, '@import "path/test.less"; I did not found that setting include-path has any effect.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JQuery .addClass() with less mixins

From Dev

LESS Variables as parametric mixins

From Dev

How can I use Bootstrap styles in a LESS file?

From Dev

Enums/Documentation with LESS Mixins

From Dev

How to call LESS Mixins outside of CSS Classes?

From Dev

How to use less mixins in meteor with @import and not get multiple definitions

From Dev

Do I need SASS or LESS to use Mixins?

From Dev

How can I get Webstorm to recognize my LESS file?

From Dev

How to use variable variables in LESS with colors stored in named variables in loops and mixins?

From Dev

How do I use Mixins without inheritance?

From Dev

How to use less by "var less = require('less');"

From Dev

How to import a .aar file into Android Studio 1.1.0 and use it in my code

From Dev

How to use mixins properly

From Dev

Can I use mixins to generate new mixins in LESS?

From Dev

How can I add Levels to my game with less duplication of code?

From Dev

JQuery .addClass() with less mixins

From Dev

How to call LESS Mixins outside of CSS Classes?

From Dev

How to use pipe-forwarding in my file read code

From Dev

creating mixins with arguments in LESS

From Dev

LESS Mixins proper way

From Dev

How can I combine my LESS file with the default bootstrap less file

From Dev

How to write html custom attribute in less use Mixins

From Dev

How to use my vim configuration in less?

From Dev

CSS Less mixins for keyframes

From Dev

How to use mixins properly

From Dev

Can I use mixins to generate new mixins in LESS?

From Dev

How to use less memory splitting file with awk

From Dev

cant read file and use it with my code

From Dev

CSS: How do I change bootstrap LESS code.less source code to customize my code coloring?

Related Related

HotTag

Archive