refactored the template mechanism
adds handling of three new characters (contributed by Mateusz Łącki)