0

i got an array from php with below code

 <script type="text/javascript">
     var params = <?php echo json_encode($this->getParams());?>;
     var variables = new Object();
     for(var key in params){
        variables[key] = "'" + params[key] + "'";
     }
    less.modifyVars(variables);
    console.log(params);
    console.log(variables);
 </script>

from console params : Object {google_font: "Abel", icon: "custom/icon.icon"}

variables : Object {google_font: "'Abel'", icon: "'custom/icon.icon'"}

and in style.less

 @bd_ggfont : @google_font;

 body{
    font-family: @bd_ggfont;
}

when i complie i get error messeger

 NameError: variable @google_font is undefined
 in style.less on line 7, column 8:

 7@bd_ggfont : @google_font;

what is wrong ? thanks for any help !!

also i change key in params to @key like

 variables['"@' + key + '"'] = "'" + params[key] + "'";

and i get error too!

Peter Jack
  • 847
  • 5
  • 14
  • 29
  • 1
    Hmm, are you trying too use two LESS compilers in the same time? The strange thing is: You call `modifyVars` inside your js script, so the `less` object there obviously represents some javascript based LESS compiler (`less.js` or `lessc` of node?) But in the same time you mention `lessphp`... so what compiler do you compile with? – seven-phases-max Oct 17 '13 at 06:30
  • Either way try http://stackoverflow.com/search?q=%5Bless%5D+modifyVars – seven-phases-max Oct 17 '13 at 06:35

0 Answers0