【问题标题】:Formatting "*.scala.html" code in IntelliJ IDEA 15 community edition在 IntelliJ IDEA 15 社区版中格式化“*.scala.html”代码
【发布时间】:2015-12-05 23:14:00
【问题描述】:

我应该在 IntelliJ IDEA 15.0.1 社区版中使用一些特殊的配置设置来正确格式化*.scala.html 文件吗?

我读到 James Ward 对他的回答发表了评论: https://stackoverflow.com/a/17478667/1065693 它应该工作,至少部分。

所以我安装了 Scala 插件并按照导入 PlayFramework 项目的说明进行操作:https://www.jetbrains.com/idea/help/getting-started-with-play-2-x.html

然后我发出了Code -> Reformat Code,但它产生了一个不再编译的代码,例如:

@(title: String)(content: Html)

@import play.i18n._

<!DOCTYPE html>

<html class="no-js" lang="pl">
    <head>
        <link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
</head>
    <body class="homepage">
        <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    </body>
</html>

转为:

@(title: String)(content: Html)

@import play.i18n._

<!DOCTYPE html>

<html class="no-js" lang="pl">
<head>
    <link rel="stylesheet" media="screen" href="@routes.Assets.versioned(" stylesheets
    /main.css")">
</head>
<body class="homepage">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</body>
</html>

/ 上中断路径会导致错误。我试图更改Editor -&gt; Code Style -&gt; HTML 中的不同设置(或者我应该使用Scala?),但没有帮助。配置中有什么可以使用的吗?

【问题讨论】:

    标签: scala intellij-idea playframework


    【解决方案1】:

    社区版不支持 Play Framework 和其他一些标准(请查看 features pages 了解更多详情)

    无论如何,您都可以尝试解决这个问题,即通过对标签的属性使用单引号(注意 W3C 声明这是绝对有效的方法)

    <link rel="stylesheet" media="screen" href='@routes.Assets.versioned("stylesheets/main.css")'>
    

    【讨论】:

    • 谢谢,使用单引号确实有帮助。
    猜你喜欢
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    相关资源
    最近更新 更多