Note that there are some explanatory texts on larger screens.

plurals
  1. POModifying Watched LESS Variables in Bootstrap
    text
    copied!<p>I am using bootstrap that defines many less variables, take<code>@body-bg</code> as an example. I created a color theme that defines <code>@background</code>. To glue the two together I do the following:</p> <pre class="lang-css prettyprint-override"><code>@body-bg: @background </code></pre> <p>Now, I want to be able to switch between color themes. So I use less' watch feature to change <code>@background</code>, but less doesn't appear to propagate this to the @body-bg and it actually switches to the bootstrap default.</p> <p>I don't want to do either of the following</p> <ul> <li><code>less.modifyVars({ '@body-bg': '#FFFF00' })</code></li> <li><code>less.modifyVars({ '@background': '#FFFF00', '@body-bg': '@background' })</code></li> </ul> <p>because there are many other variables that are defined from <code>@background</code>.</p> <p>Here are some test pages.</p> <p><strong>Problem.htm</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet/less" type="text/css" href="problem.less" /&gt; &lt;script src="//cdnjs.cloudflare.com/ajax/libs/less.js/1.4.1/less.min.js#!watch" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="#" onclick="less.modifyVars({ '@background': '#FF0000' })"&gt;Apple Style!&lt;/a&gt; &lt;a href="#" onclick="less.modifyVars({ '@background': '#FFFF00' })"&gt;Banana Style!&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>problem.less</strong></p> <pre class="lang-css prettyprint-override"><code>@background: #FF0000; @import "bootstrap/bootstrap.less"; @body-bg: @background; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload