sinatra/haml 中未初始化常量 Tilt::CompileSite::Nokogiri 错误
我有一个两行脚本,可以在 ruby 中很好地工作。 收到错误
我将其移至 haml 并在 / 处 NameError 未初始化的常量 Tilt::CompileSite::Nokogiri
haml 代码:
%td
- @doc = Nokogiri::XML(File.open(file))
= @doc.xpath("//testsuite").each_with_index {|node,index| "#{index+1}. #{node.attributes["name"].value}<BR>" }
知道如何让它工作吗?
上使用以下内容
- 在 Win XP SP3 ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
- nokogiri (1.4.3.1 x86-mingw32)
- sinatra (1.0)
- Thin (1.2.7 x86-mswin32)
I have a two line script that works nicely in ruby. I moved it to haml and getting the error
NameError at /
uninitialized constant Tilt::CompileSite::Nokogiri
the haml code:
%td
- @doc = Nokogiri::XML(File.open(file))
= @doc.xpath("//testsuite").each_with_index {|node,index| "#{index+1}. #{node.attributes["name"].value}<BR>" }
any idea how I can make it work?
using below on Win XP SP3
- ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
- nokogiri (1.4.3.1 x86-mingw32)
- sinatra (1.0)
- thin (1.2.7 x86-mswin32)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
仍然不知道为什么会发生错误,但我通过在 sinatra 文件中定义一个函数并在 haml 文件中调用它来解决它
= get_testsuite(file)
still do not know why the error happens but I solved it by have a function defined in sinatra file and calling it in haml file
= get_testsuite(file)