I've been messing around with lessphp and bootstrap-colorpicker and I'd like to find out if it's possible to override less variables with a hex color set by bootstrap-colorpicker, something like:
<?php
if(isset($_POST['submit'])){
require "lessc.inc.php";
$less = new lessc;
$less->setVariables(array("bodyBackground" => $_POST['color']));
$less->checkedCompile("less/bootstrap.less", "output.css");
try{
$less->compile("invalid LESS } {");
}catch(exception $e){
echo "fatal error: " . $e->getMessage();
}
}?>
markup:
<form method="post" action="">
<input name="color"
type="text"
class="span3"
value="<?php if(isset($_POST['color'])){echo $_POST['color'];}else{echo
'#8fff00';}?>"
id="cp1" />
<input name="submit" class="btn btn-primary" type="submit" value="Submit"/>
</form>
<script>
$function(){
var bodyStyle = $('body')[0].style;
$('#cp1').colorpicker({format: 'hex'}).on('changeColor', function(ev){
bodyStyle.backgroundColor = ev.color.toHex();
});
</script>
I thought this would work but it doesn't, I'm not totally sure that setVariables is passing the POST data as @bodyBackground: #new_hex;
since i'm currently getting the default value of bootstrap's @white
less variable. I'm new to lessphp and was wondering if its possible to assign new values to bootstrap less variables before compiling?
Thanks in advance