Escaped erb bug fix.

ref #1256 
This approach is checking a existence of app.
We also have a [dario's approach](https://gist.github.com/dariocravero/a35a59b6d45cd3b49c0d) as an alternative.
What do you think?