Over the last decade, the Common Information Model (CIM), as specified by IEC 61970 / 61968, has become an important document format for the storage of power grid data. Its object-oriented design makes it easily maintainable and extensible for many use cases in the energy sector. As a result, more and more power grid analysis and simulation tools allow the import and export of CIM based power grid data. Unfortunately, many of them are proprietary and therefore not convenient in the research area since their component models and numerical back-ends often cannot be modified by the user. Thus, open-source alternatives are in demand, such as simulation environments based on the popular modeling language Modelica. Therefore, this paper presents our approach of a template based CIM to Modelica converter. The usage of templates makes it easily adaptable for the generation of Modelica system models targeting arbitrary Modelica libraries. The presented approach is implemented in an open-source project called CIMverter, evaluated on a real-world case with two Modelica power system libraries, and validated against a proprietary simulation tool.