English 中文(简体)
如何在jade(不连接)列入一只 c子档案
原标题:How to include a css file in jade (without linking it)
  • 时间:2012-05-15 06:54:26
  •  标签:
  • node.js
  • pug

我有这份小标题:

!!! 5
html
  head
    title test include
    style(type= text/css )
      //- DOES NOT WORK!
      include test.css
  body
    //- works
    include test.css
    div 
      //- works
      include test.css

产出:

$ jade -P test.jade 
rendered test.html
$ cat test.html
<!DOCTYPE html>
<html>
  <head>
    <title>test include</title>
    <style type="text/css">
      //- DOES NOT WORK!
      include test.css
    </style>
  </head>
  <body>body { color: peachpuff; }

    <div> body { color: peachpuff; }

    </div>
  </body>
</html>

当然,我可以简单地把档案联系起来,但我不想这样做。

最佳回答

我没有测试过它(不是在我的计算机自动取款机上),但有机会做这样的工作:

!!!
head
  title test include
  | <style type= text/css >
  include test.css
  | </style>

顺便提一下,我发现超文本2Jade在线转换器,而不是Jade2超文本。 如何找到?

问题回答

http://jade-lang.com/vis/includes/“rel=“noretinger”>jade docs :

doctype html
html
  head
    style
      include style.css
  body
    h1 My Site
    p Welcome to my super lame site.

它完美无缺。

通过fs,作为数据,你可以

style !{fs.readFileSync("index.css").toString()}

Arnaud的回答对我来说是好的,但我自那以来发现,这并不更清洁:

doctype
head
  title test include
  style(type="text/css"): include test.css

在目前版本的Jade(0.35.0)中,t 足以书写<>/strong>> 。

完整的实例(认为你是书面索引.jade,该索引位于views ,而你的风格则载于assets/code> 。

!!!
html
   head
       include ../assets/bootstrap3/css/bootstrap-theme.css
       include ../assets/bootstrap3/css/bootstrap.css
body
   h1 Hi!

www.un.org/spanish/ecosoc 请注意,模板中没有<代码> 字面 tag,将自动插入斜体(如冰箱!)。

style(type="text/css").
  #{css}

try this with pug.render(..., { css: yourCssString })

A possible solution would be:

style(type="text/css")
    #{css}

And then pass the css-text in the res.render(...) call.





相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

热门标签