Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modifyVars does not work with string path #2372

Closed
jimmyphong opened this issue Jan 6, 2015 · 4 comments
Closed

modifyVars does not work with string path #2372

jimmyphong opened this issue Jan 6, 2015 · 4 comments

Comments

@jimmyphong
Copy link

i try to work with less js and available string path in less

code

available.less

    @image-path : "/assets/images";

    @bg-image : "/bg/01.png";

style.less

  @import "available.less";
   body{
       background: url('@{image-path}@{bg-image}') repeat top left;
   }

in javascript

   less.modifyVars({
    '@bg-image' : "/bg/08.png"
});

i get error ParseError: Unrecognised input

@bg-image: /bg/08.png;

how to fix it

so if i change modifyVars to

   less.modifyVars({
    '@bg-image' : "'/bg/08.png'"
});

with value wrap in double quote + single qoute it work !

Thanks

@lukeapage
Copy link
Member

I think thats what you have to do.. its hard to guess whether its a string
or a value or a color etc.

@seven-phases-max
Copy link
Member

Yep, this is expected since '@bg-image': "/bg/08.png" means @bg-image: /bg/08.png; which is invalid Less statement. In JavaScript you have to use double pair of quotes there (one pair of quotes is for JS and the second pair is for Less).

@sinuhedev
Copy link

hi, try the following example

var less = require('less');
less.render("@icon-font-path: '../lib/bootstrap/fonts/'; .class { src: @icon-font-path };", {
"compress" : false,
"modifyVars" : {'icon-font-path':"'fonts/'"}
}, function(e, output) {
console.log(output.css);
});

@seven-phases-max
Copy link
Member

Closing as expected behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants