5
我希望能夠創建一個網頁臨時文件的目錄,其中每個文件是一個獨立的頁面。是否有可能將Stylus插件與鑲嵌在Jade文件中的嵌入式Stylus代碼一起使用?
這與常規的HTML/CSS/JS很簡單:
<head>
<style>
p {
color: red;
}
</style>
</head>
<body>
<p>lololol</p>
</body>
而且它同樣容易玉/手寫筆/ CoffeeScript的:
head
:stylus
p
color red
body
p lololol
的事情是,有沒有明確的辦法使用Stylus插件這種方式。具體來說,我想使用colorspaces.js和筆尖更有效地與色彩實驗:
head
:stylus
@import 'nib'
p
color CIELCH(20.470, 74.265, 314.113)
background-color linear-gradient(white, black)
body
p lololol
解決方法我目前使用
您可以派生玉通過改變these lines像這樣:
/**
* Transform stylus to css, wrapped in style tags.
*/
stylus: function(str, options){
+ colorspaces = require('colorspaces');
+ nib = require('nib');
var ret;
str = str.replace(/\\n/g, '\n');
var stylus = require('stylus');
- stylus(str, options).render(function(err, css){
+ stylus(str, options).use(colorspaces()).use(nib()).render(function(err, css){
if (err) throw err;
ret = css.replace(/\n/g, '\\n');
});
return '<style type="text/css">' + ret + '</style>';
},
如果你我nstall Jade的依賴關係(我必須npm install commander
和npm install mkdirp
),您可以導航到/jade_fork/bin/
並執行./jade name_of_file.jade
。
但我寧願留在翡翠的主要分支爲維護的原因。
謝謝,這個(新答案)很好用! –