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.
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.