You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-29 16:16:38 +00:00
Add ability to use custom script templates.
Templates will be loaded from .godot/script_templates For now they're disabled for GDNative. Ideas for further improvements: - Add a "Save as Template" option to the script editor, as it can normally only save to res:// - Support more placeholders / custom placeholders
This commit is contained in:
@@ -69,6 +69,19 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
|
||||
return script;
|
||||
}
|
||||
|
||||
bool GDScriptLanguage::is_using_templates() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GDScriptLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {
|
||||
|
||||
String src = p_script->get_source_code();
|
||||
src = src.replace("%BASE%", p_base_class_name);
|
||||
src = src.replace("%TS%", _get_indentation());
|
||||
p_script->set_source_code(src);
|
||||
}
|
||||
|
||||
bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const {
|
||||
|
||||
GDParser parser;
|
||||
|
||||
Reference in New Issue
Block a user