Skip to content

Commit

Permalink
modified parsing of template string and added 'hidden' attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquin30 committed Dec 15, 2024
1 parent a9c7193 commit 074b522
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion addons/block_code/code_generation/block_definition.gd
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,21 @@ func get_output_parameters() -> Dictionary:


static func parse_display_template(template_string: String):
# separate the template string by | character
# for normal and advanced parameters
var sep = template_string.find("|")
var template_string_normal: String
var template_string_advanced: String
if sep == -1:
template_string_normal = template_string
template_string_advanced = ""
else:
template_string_normal = template_string.substr(0, sep).trim_suffix(' ')
template_string_advanced = template_string.substr(sep+1)

var items: Array[Dictionary]
for regex_match in _display_template_regex.search_all(template_string):
# Parse the normal part of the template string
for regex_match in _display_template_regex.search_all(template_string_normal):
if regex_match.names.has("label"):
var label_string := regex_match.get_string("label")
items.append({"label": label_string})
Expand All @@ -105,6 +118,20 @@ static func parse_display_template(template_string: String):
elif regex_match.names.has("const_parameter"):
var parameter_string := regex_match.get_string("const_parameter")
items.append({"const_parameter": _parse_parameter_format(parameter_string)})
# Parse the advanced part of the template string
for regex_match in _display_template_regex.search_all(template_string_advanced):
if regex_match.names.has("label"):
var label_string := regex_match.get_string("label")
items.append({"label": label_string, "hidden": true})
elif regex_match.names.has("in_parameter"):
var parameter_string := regex_match.get_string("in_parameter")
items.append({"in_parameter": _parse_parameter_format(parameter_string), "hidden": true})
elif regex_match.names.has("out_parameter"):
var parameter_string := regex_match.get_string("out_parameter")
items.append({"out_parameter": _parse_parameter_format(parameter_string), "hidden": true})
elif regex_match.names.has("const_parameter"):
var parameter_string := regex_match.get_string("const_parameter")
items.append({"const_parameter": _parse_parameter_format(parameter_string), "hidden": true})
return items


Expand Down

0 comments on commit 074b522

Please sign in to comment.