Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 用纯Ruby编写Rails模板_Ruby On Rails_Ruby_Ruby On Rails 3_View - Fatal编程技术网

Ruby on rails 用纯Ruby编写Rails模板

Ruby on rails 用纯Ruby编写Rails模板,ruby-on-rails,ruby,ruby-on-rails-3,view,Ruby On Rails,Ruby,Ruby On Rails 3,View,我的Rails应用程序中有大量视图,它们都是: 具有一致且重复的结构,以及 包括使用接受大型散列输入的帮助程序 因此,我希望直接用Ruby编写这些视图(使用我将编写的DSL/helpers) 如何让Rails允许我编写.html.rb视图 谢谢 添加具有以下内容的初始值设定项: ActionView::Template.register_template_handler(:rb, :source.to_proc) 然后您可以用ruby编写.html.rb视图,它们在执行时应该返回所需上下文

我的Rails应用程序中有大量视图,它们都是:

  • 具有一致且重复的结构,以及
  • 包括使用接受大型散列输入的帮助程序
因此,我希望直接用Ruby编写这些视图(使用我将编写的DSL/helpers)

如何让Rails允许我编写
.html.rb
视图


谢谢

添加具有以下内容的初始值设定项:

ActionView::Template.register_template_handler(:rb, :source.to_proc)

然后您可以用ruby编写
.html.rb
视图,它们在执行时应该返回所需上下文的
字符串。

现有解决方案(如Markaby、Arbre等)有什么问题?我也不明白你的要点是如何需要用Ruby编写的;这些问题看起来是正交的。这里可以找到一些开头的信息:@DaveNewton,尝试将大型多行哈希插入HAML。@thomasfedb签出HAML filters@marianisen,我有。我使用
:ruby
过滤器。谢谢你。