Conditional display of text in GSP file in Grails - Messages from mrhaki
GSP上で実行モード別のコードを記述する方法。ifタグでできるそうな。
<g:if env="production"> ...JS code for Google Analytics... </g:if>
ちょっと覚えておくといいかもダ。ちなみに,ControllerやScriptなどのロジック中は,GrailsUtil.getEnvironment()
とかisDevelopmentEnv()
を使うのは知ってた。
#別にGrailsUtilをGSPで使っちゃダメというワケではない。
switch(GrailsUtil.environment){ case "development": // developmentんときの振る舞い break case "test": // testんときの振る舞い break case "production": // procuctionんときの振る舞い break }
どうでもいいが,こうして見ると,breakしないとfall throughするswitch文ってのは,結構だせぇな。:-)