Templates: Fixed a problem with macro replacement.

- Fixed a problem with macro replacements containing macros with flags.