Templars are a social and sometimes adventuring class for Dungeons & Dragons native to the Dark Sun setting. Templar is the generic term used for the various mystic-bureaucrats who directly serve the will of the various Sorcerer-Kings, using a combination of magical powers drawn directly from their worship of a patron Sorcerer-King and their social rank as lawmakers and city-guard to enforce their master's will.
In the original Dark Sun setting, they were a variant Priest class, gaining spellcasting slots more slowly than the conventional Cleric, but with much more spellslots available to them by the time they maxed out their class. They also had the ability to create scrolls and potions, lacked any arms & armor restrictions, and had social-related powers in their native city-state due to their serving as the legal arm of the Sorcerer-King. However, they had to be Neutral or Evil in alignment, since, y'know, they were a brutal bunch of self-serving enforcers and power-mongers, worshipping and serving evil tyrants like gods.
They lost this status in the Revised Edition of the Dark Sun setting. Although still a social class, they were restricted to NPCs, although as "Templar" was emphasized as being a social state, one could still technically play an (ex) Templar by fluffing an elemental Cleric or a Defiler (especially a hybrid or multiclassed Fighter/Defiler) in the right way.
The Athas Dot Org 3E update made Templars charisma based Clerics with better weapon options, more skill points and spell progression in exchange for a more restricted spell list and the RP problem of being the bitch of one of the setting's main antagonists that walks around with a target on their back if you were fighting a different one of the main antagonists. The Dragon Magazine update instead just made Templars clerics of the dragon kings.
4th edition took a look at the history of Templars and decided they fit perfectly under the Warlock umbrella, simply creating a new Pact, the Sorcerer-King, to represent the origins of their magic and creating unique new spells to go with it. This was in addition to making Templars as a theme, which keyed them to supporting teammates by giving them better means to hit enemies and benefits like a Leader class.