Improve template handling in FormHelper

These changes introduce an internal template stack in `StringTemplate` which allows for both `create()`/`end()` to push/pop the template stack solving #3124. It also cleans up the internals of `input()` and allows a templates file to be used there as well solving #4015.