如何撤消Haml中的Rails模板生成? [英] How do I undo Rails template generation in Haml?

查看:40
本文介绍了如何撤消Haml中的Rails模板生成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails项目中安装了一个新的宝石-短语,该宝石与多个Haml宝石具有依赖关系。我需要gem(它为我的项目添加了一些惊人的功能),并且需要安装依赖项,但是现在当我运行 rails generate scaffold 时,所有视图模板是在Haml中而不是ERB中生成的。我需要继续在ERB中生成视图。

I installed a new gem to my Rails project - 'phrasing' - which has gem dependencies on multiple Haml gems. I need the gem (it is adding some phenomenal functionality to my project), and need the dependencies to be installed, but now when I run rails generate scaffold, all of the view templates are generated in Haml rather than ERB. I need views to continue to be generated in ERB.

我回顾了之前的StackOverflow文章,但是大多数文章着重于转换为Haml,并给出了确保ERB为默认生成器是指从配置文件中删除行,在我的情况下这些行不存在(看来gems正在以某种方式控制默认布局格式)。

I reviewed several previous StackOverflow articles, but most focus on converting TO Haml, and the answers around making sure that ERB is the default generator refer to removing lines from the config files, which are not there in my case (it appears that the gems are controlling the default layout format somehow).

注意:尽管我很欣赏使用Haml可能有很多优点,并且我可能会考虑在新项目中使用它,但我希望保持一致,并且已经完成了80% ERB。)

(Note: While I appreciate that there may be several advantages to using Haml, and I might consider using it in a new project, I'd like to keep this one consistent, and it's already 80% finished in ERB.)

推荐答案

原来,这就像将以下内容添加到 class Application

Turns out this was as simple as adding the following into class Application in the config/application.rb file:

config.generators do |g|
   g.template_engine :erb
end

仍然不确定为什么要手动覆盖是必要的,但这是必需的。这样就可以解决。

Still not sure why the manual override was necessary, but it is. This fixes it.

这篇关于如何撤消Haml中的Rails模板生成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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