Smarty improvements

Various Smarty extension improvements to fix #4553.

**TODO**:

- [ ] unit test template inheritance
- [ ] update docs to reflect all changes.
- [ ] update changelog to reflect all changes.