Improved macros

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #861, #867, #929, #1052
| License       | MIT
| Doc        | yes

* Fixed fatal error for unknown macro
* Added support for named arguments for macros
* Added support for directly call macros defined in the same template