libsas绑定
SassPython的Python项目详细描述
为什么?
- 这个谈话的人要求这样做:http://www.confreaks.com/videos/859-railsconf2012-the-future-of-sass
- 我想玩cTypes
谁?
马里亚诺格拉
怎么做?
首先下载、编译并安装libsass:
git clone https://github.com/hcatlin/libsass.git cd libsass ./configure make sudo make install
然后,您可以通过两种方式使用此项目
命令行
如果没有提供选项,请从stdin读取:
➜ src ./sass.py table.hl td.ln { text-align: right; } table.hl td.ln { text-align: right; }
从文件:
➜ src ./sass.py -f ../examples/simple.scss .content-navigation { border-color: #3bbfce; color: darken(#3bbfce, 9%); } .border { padding: 8px; margin: 8px; border-color: #3bbfce; }
从文件夹:
# I think it doesn't work, never used sass before and don't know what # this means :) ➜ src ./sass.py -d ../examples/
你不能一边嚼口香糖一边走路:
➜ src ./sass.py -f ../examples/simple.scss -d ~ usage: sass.py [-h] [-f FILE_PATH | -d DIR_PATH] sass.py: error: argument -d/--dir: not allowed with argument -f/--file
代码
从字符串:
Python 2.7.3 (default, Apr 20 2012, 22:44:07) >>> import sass >>> STYLE = """ ... table.hl td.ln { ... text-align: right; ... } ... """ >>> ok, style = sass.compile(STYLE) >>> ok True >>> print style table.hl td.ln { text-align: right; }
从文件:
>>> ok, style = sass.compile_path("../examples/simple.scss") >>> ok True >>> print style .content-navigation { border-color: #3bbfce; color: darken(#3bbfce, 9%); } .border { padding: 8px; margin: 8px; border-color: #3bbfce; }
从文件夹:
>>> ok, style = sass.compile_folder("../examples/") # ??? # Profit!
如何安装?
来源
Python2:
sudo python2 setup.py install
Python3:
sudo python3 setup.py install
使用pip
sudo pip install SassPython
执照?
麻省理工学院+创作者可选啤酒
还有什么事要做?
- 使文件夹工作
- 添加命令行选项以指定选项样式
- 查看编译返回值的含义,并在需要时使用它