We propose a design scheme for potential electrides derived from conventional materials. Starting with rare-earth-based ternary halides, we exclude halogens and perform global structure optimization to obtain thermodynamically stable or metastable phases but having an excess of electrons confined inside interstitial cavities. Then, spin-polarized interstitial states are induced by chemical substitution with magnetic lanthanides. To demonstrate the capability of our approach, we test with 11 ternary halides and successfully predict 30 stable and metastable phases of nonmagnetic electrides subject to 3 different stoichiometric categories, and successively 28 magnetic electrides via chemical substitution with Gd. 56 out of these 58 designed electrides are discovered for the first time. Two electride systems, the monoclinic $A$C ($A=$ La, Gd) and the orthorhombic $A_2$Ge ($A=$ Y, Gd), are thoroughly studied to exemplify the set of predicted crystals. Interestingly, both systems turn out to be topological nodal line electrides (TNLE) in the absence of spin-orbit coupling and manifest spin-polarized interstitial states in the case of $A=$ Gd. Our work establishes a novel computational approach of functional electrides design and highlights the magnetism and topological phases embedded in electrides.