在Meteor中访问手写笔中的Javascript变量

在Meteor中访问手写笔中的Javascript变量,javascript,meteor,coffeescript,stylus,Javascript,Meteor,Coffeescript,Stylus,我正在用Meteor做一个游戏,我正在尝试使用S-grid创建一个随机大小的网格,在那里我用Javascript(Coffeescript)获取列变量,并用手写笔访问它们 My.coffee文件在lib文件夹中,My main.styl文件在client文件夹中 random = (num) -> Math.floor Math.random() * num + 1 @cols = random() @rows = random() stylus = require('stylus

我正在用Meteor做一个游戏,我正在尝试使用S-grid创建一个随机大小的网格,在那里我用Javascript(Coffeescript)获取列变量,并用手写笔访问它们

My.coffee文件在lib文件夹中,My main.styl文件在client文件夹中

random = (num) ->
  Math.floor Math.random() * num + 1

@cols = random()
@rows = random()

stylus = require('stylus')

stylus(str)
  .set('filename', '../client/main.styl')
  .define 'cols', stylus.nodes.unit(@cols)
  .define 'rows', stylus.nodes.unit(@rows)
  .render (err, css) ->
    if (err)
      throw err
    console.log(css)
    return
我在构建应用程序时遇到此错误:
node_modules/stylus/node_modules/glob/node_modules/minimatch/node_modules/lru cache/test/memory leak.js:1:15:意外令牌非法
node_modules/stylus/node_modules/source map/test/run tests.js:1:15:意外令牌非法
node\u modules\stylus\node\u modules\sax\examples\test.html:1:无法在此处设置DOCTYPE。(流星为你而设)
node\u modules\stylus\node\u modules\sax\LICENSE-W3C.html:1:无法在此处设置DOCTYPE。(流星为你而设)
纯手写笔网格工作正常,但我似乎无法通过Javascript设置列。


我这样定义我的网格

.grid
  grid()
   .box
     cells(1, @cols)

其中
@cols
是来自javascript变量的随机数。如果我使用一个通用数字或使用手写笔生成随机数字,它可以正常工作,但我需要JS变量(我使用它做其他事情)。我不知道如何在.styl中创建它并在JS中访问它。

在styl文件中定义此函数并包括它:

random(num)
    return math(math(0, 'random') * num + 1, 'floor')

像往常一样在手写笔文件中使用随机数。

我试过了,效果不错,但问题是我在Javascript和CSS中都需要相同的随机数。到目前为止,我有两个随机数,一个在coffee文件中,另一个在styl文件中。在javascript中,您可以使用jqueryI从元素中读取生成的数字。我已经尝试过了,但是S-Grid没有生成属性或任何我可以访问的内容。我还没有看到,我一直在使用Firefox开发工具,但到目前为止什么都没有。