Function hyper_scripter::path::get_template_path
source · pub fn get_template_path<T: AsScriptFullTypeRef>(ty: &T) -> Result<PathBuf>Examples found in repository?
More examples
src/util/mod.rs (line 163)
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
pub fn get_or_create_template_path<T: AsScriptFullTypeRef>(
ty: &T,
force: bool,
check_subtype: bool,
) -> Result<(PathBuf, Option<&'static str>)> {
if !force {
Config::get().get_script_conf(ty.get_ty())?; // 確認類型存在與否
}
let tmpl_path = path::get_template_path(ty)?;
if !tmpl_path.exists() {
if check_subtype && ty.get_sub().is_some() {
return Err(Error::UnknownType(ty.display().to_string()));
}
let default_tmpl = get_default_template(ty);
return write_file(&tmpl_path, default_tmpl).map(|_| (tmpl_path, Some(default_tmpl)));
}
Ok((tmpl_path, None))
}