Fix #2237: Parser library failed if the same tag pair is used more than once within a template

(manually applying PR #2238 + updated unit tests)
3 files changed