Visual Studio 2013 HTML/Razor ファイルのアンミニファイとは?

先日、社内でたまたま話題にあがった、あまり知られていない? Visual Studio 2013 の機能「アンミニファイ」について簡単にご紹介します。(とは言え、あまり使う機会がない機能な気もしますので、こんなこともできるんだ、くらいの気持ちで読んでくださいw)

● アンミニファイ (Un-minify)

Visual Studio 2013 のプロジェクトで、HTML ファイルまたは Razor ファイル (.cshtml) 上で右クリックすると、(控えめに)「アンミニファイ」というメニュー項目が表示されます。

image

最初は私も「なんだ?このメニュー?」と思い、クリックするも何も変化が起こらず「むむむ?」という感じだったのですが、下記のブログに書かれている通り、ミニファイされた HTML/Razor ファイルをエクスパンドするコマンド、つまり改行なしの HTML/Razor ファイルを整形するコマンドだそうです。

HTML Editing Features in Visual Studio 2013 RC

Un-minify
If you right-click on an HTML or Razor file, the last command in the context menu is “Un-minify.” In RC, this command does nothing, but was included to ensure that the localization process was completed for all shipping languages. In RTM this command will expand minified HTML files.

次のような HTML で実行すると ...

 <!DOCTYPE html><html lang="en"><head><title>Un-minify</title></head><body><h1>んちゃ!</h1></body></html>

こんな感じ↓に整形されました。

 <!DOCTYPE html>
<html lang="en">
<head>
    <title>Un-minify</title>
</head>
<body>
    <h1>んちゃ!</h1>
</body>
</html>

まれに、改行無しの HTML ファイルに遭遇したら、この機能を思い出してくださいね・・・