- 
    Bug 
- 
    Resolution: Fixed
- 
    Medium 
- 
    3.5, 5.0-OD-27
- 
    None
NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.
When you add a macro to a template, some of them (like TOC, Page Tree Search or Page Tree) fail to preview (but they work completely fine when the template is used afterwards) because they expect a space to exist. This is true even when creating a space template, which is bad.
The error thrown when creating a TOC macro on a template is:
Error rendering macro 'toc' : null
- relates to
- 
                    CONFCLOUD-27660 Macros doesn't render on template preview -         
- Closed
 
-         
- 
                    CONFSERVER-23346 Previewing a template containing a table of contents macro will show a NullPointerException -         
- Closed
 
-         
- 
                    CONFSERVER-25590 Pagetree macro throws NullPointerException in Global Template Preview -         
- Closed
 
-         
- is blocked by
- 
                    TOC-164 Loading... 
- mentioned in
- 
                    Wiki Page Loading... 
