added support for removing dom elements before compiling templates