节点应用程序变量传入触笔文件 [英] Node app variables passed into stylus file

查看:102
本文介绍了节点应用程序变量传入触笔文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个小节点应用程序,并用Jade和Stylus使用Express来渲染一些基本的HTMl页面。

I am building a little node app and using Express with Jade and Stylus to render some basic HTMl pages.

如果有一种方法可以将一些变量INTO传递给从Node生成的.styl文件,我很好奇我很清楚,我可以在.styl文件中定义变量,但是我需要更加动态。具体来说,我正在寻找一种容易的方法来存储数据库中的一些颜色,有节点抓住这些值,然后将它们插入到.styl文件中,以便当页面呈现时,这些变量被传入。似乎应该这样做但我缺乏细节。任何帮助是赞赏。谢谢!

I was curious if there is a way for me to pass some variables INTO the .styl file that are generated from Node? I am well aware that i can define variables inside of the .styl file but I have a need to be more dynamic. Specifically i was looking for an easy way to store some colors in the db, have node grab those values, then insert those into the .styl file so that when the page is rendered these variables are passed in. It seems like this should be do-able but i am lacking on the details. Any help is appreciated. Thanks!

推荐答案

您可以使用Stylus API的 define()函数来设置Stylus变量并使JS函数可用。

You can use the Stylus API's define() function to set Stylus variables and make JS functions available to it.

这篇关于节点应用程序变量传入触笔文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆