How to pass a variable from PHP to LESS?

时间秒杀一切 提交于 2019-11-30 04:20:27

问题


I use PHP (lessphp) to compile LESS files into CSS files on the serverside. I would like to pass a variable to the LESS file, like a color or a language:

compile('input.less?lang=en')

and use it as a variable in LESS like @lang.

Is this possible? If not, are there any workarounds?


回答1:


This is a built in feature of lessphp, here's the documentation: http://leafo.net/lessphp/docs/#setting_variables_from_php




回答2:


I don't know less or lessphp so this may not be helpful and you may have already looked at it, but on the site I notice someone else has asked the same question and there are a couple of responses:

http://leafo.net/lessphp/#dsq-comment-132897969 (You'll have to wait for it to load the comments from disqus)

It looks like Nico-B has developed a patch to do this: https://github.com/Nico-B/lessphp/commit/aacc195fff4ec0075226a29bc832de371a8001ce#diff-1



来源:https://stackoverflow.com/questions/8136331/how-to-pass-a-variable-from-php-to-less

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!