move code from TagLibraryApi to TagLibrary trait