pub fn get_template_path<T: AsScriptFullTypeRef>(ty: &T) -> Result<PathBuf>
Examples found in repository?
src/util/main_util.rs (line 344)
342
343
344
345
346
347
348
349
350
351
pub fn load_templates() -> Result {
    for (ty, tmpl) in iter_default_templates() {
        let tmpl_path = path::get_template_path(&ty)?;
        if tmpl_path.exists() {
            continue;
        }
        super::write_file(&tmpl_path, tmpl)?;
    }
    Ok(())
}
More examples
Hide additional 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))
}