Added support for directly call macros defined in the same template

Fixes: #861, #867
Depends on #933