我可以忽略代码中的 "twitter bootstrap is deprecated" 警告吗?

Can I ignore the "twitter bootstrap is deprecated" warnings in my code?

我正在使用 play framework 2.3.8 和 twitter Bootstrap 3.3.4,我的应用程序中有几个表单,您可以在其中输入内容。

样本:

@import models.Question
@import models.Answer
@import helper._
@import helper.twitterBootstrap._

@(questionForm: Form[Question], questionList: List[Question])

@main("Ask Question"){

    @helper.form(action = routes.Application.sendQuestion()){
        <fieldset>
            @helper.inputText(questionForm("questionID"))
            @helper.inputText(questionForm("questionText"))
            @helper.inputText(questionForm("voteScore"))
            @helper.inputText(questionForm("userID"))
            @helper.inputText(questionForm("page"))
        </fieldset>
        <input type="submit" class="btn btn-default">
    }
}

现在,如果我编译,终端中有几个警告:

[warn]                  @helper.inputText(questionForm("userID"))
[warn]                                   ^
[warn] (...)\frageAntwort.scala.html:22: 
value twitterBootstrapField in package twitterBootstrap is deprecated: 
The twitter bootstrap field constructor will be removed from Play in 2.4 
since the way Bootstrap must be used changes too frequently and too 
drastically between versions for this to make sense to be in the core of Play

我搜索了警告,只找到了这个 old SO post about it and an issue on github

SO post 提到要编写他自己的模板助手,但由于我自己的模板助手正在工作,所以我认为还没有必要编写一个。那么我是否仍然可以使用我的并忽略警告,或者我以后会在我的生产系统或其他任何地方遇到麻烦吗?另外,如果警告没有任何后果,是否有办法隐藏它们?

Play 2.3 migration guide 中有一节旨在解释该问题。它说:

The in-built Twitter Bootstrap field constructor has been deprecated, and will be removed in a future version of Play.

There are a few reasons for this, one is that we have found that Bootstrap changes too drastically between versions and too frequently, such that any in-built support provided by Play quickly becomes stale and incompatible with the current Bootstrap version.

Another reason is that the current Bootstrap requirements for CSS classes can’t be implemented with Play’s field constructor alone, a custom input template is also required.

Our view going forward is that if this is a feature that is valuable to the community, a third party module can be created which provides a separate set of Bootstrap form helper templates, specific to given Bootstrap versions, allowing a much better user experience than can currently be provided.

即使现在有效,将来也可能会出现问题。如果我是你,我会愿意编写自定义解决方案。只有这样,您才能确保在您的项目中进行框架升级后,一切仍能正常工作。

现在 Play-Bootstrap 支持 Bootstrap 3 和 Bootstrap 4 以及 Play 2.4 和 Play 2.5。

SNAPSHOT 构建不能直接加载,你必须这样做

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
libraryDependencies ++= Seq(
  "com.adrianhurt" %% "play-bootstrap" % "1.1-P25-B3-SNAPSHOT"
)

(来源:https://github.com/adrianhurt/play-bootstrap/blob/master/play25-bootstrap3/sample/build.sbt