【问题标题】:Node.JS Vash TypeError: while rendering template object is not a functionNode.JS Vash TypeError:渲染模板对象不是函数时
【发布时间】:2014-08-30 00:24:46
【问题描述】:

还有另一个帖子涵盖了这个,但我不允许在上面发帖。另外,唯一的答案似乎没有解决我的问题。

我在使用 @html.extend() 方法时收到 Object not a function 错误。我已经阅读了关于这个主题的所有非常有限的主题。他们都说同样的话。我需要确保我正在扩展的 layout.vash 文件的路径正确。我的声明在我想用我的 layout.vash 文件扩展的文件中看起来像这样。

@html.extend('layout', function (model) {

     .... do stuff ...

})

奇怪的是,有些页面可以正常工作,而有些则不能。路径是正确的。我确信这一点,因为同一导演中的文件表现出不同的行为。

有谁知道我可能会犯什么其他错误导致此错误?

【问题讨论】:

    标签: node.js vash


    【解决方案1】:

    在我的情况下,vash 无法解析 ... 中的内容

    我将它从布局页面中拉出来并创建了一个单独的 .css 文件,恼人的“对象不是函数”错误消失了。

    我推测 vash 与某些 css 语法冲突。 供您参考,造成麻烦的我的风格陈述是这些。

      <style type="text/css">
      *{padding:0;margin:0;}
      html{border-top:10px #1abf89 solid;}
      body{width:800px;margin:0 auto;padding:5% 20px 20px;font-family:Palatino, Optima, Georgia, serif;}
      @media all and (max-width:1024px){ body, pre a{width:60%;} }
      small{color:#999;}
      #toolbar{margin-bottom:1em;position:fixed;left:20px;margin-top:5px;}
      #toolbar [class^="icon-"]:before, #toolbar [class*=" icon-"]:before{font-family:'pen'}
      #mode{color:#1abf89;;cursor:pointer;}
      #mode.disabled{color:#666;}
      #mode:before{content: '\e813';}
      #hinted{color:#1abf89;cursor:pointer;}
      #hinted.disabled{color:#666;}
      #hinted:before{content: '\e816';}
    
      #fork{position:fixed;right:0;top:0;}
    
      /*
      When the webpage is printed
      this media query hides extra elements,
      and makes the text content fit the page.
      */
      @media print {
        #fork, #toolbar {
            display: none;
        }
        body {
            width: 94%;
            padding-top: 1em;
            font-size: 12px;
        }
        html {
            border-top: 0;
        }
      }
      </style>
    

    【讨论】:

    • 几个月后才看到这个。 ;) 我认为您的问题是需要转义 @ 标志。对于 Vash,@ 符号具有非常重要的意义。在不转义的情况下,Vash 将尝试编译以下内容。
    猜你喜欢
    • 2014-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多