obsidian-paste-image-rename
                                
                                 obsidian-paste-image-rename copied to clipboard
                                
                                    obsidian-paste-image-rename copied to clipboard
                            
                            
                            
                        trim dashes from empty variables
Is your feature request related to a problem? Please describe. it is a little bit unhandy that empty variables lead to unnecessary dashes in the filename
{{dirName}}-{{imageNameKey}}-{{fileName}}
leads to --my_file_name.png or my_dir_name--my_file_name if
Describe the solution you'd like i assume that the easiest solution would be to hardcode a trim for dashes at the beginning and the end of the resulting image filename.
Describe alternatives you've considered a more complex but quite nice solution would be to allow to define a pre and suffix in the variable, which are simply omited if the variable is empty
{{dirName:-}}{{__:imageNameKey:__}}{{fileName}}
- empty dirName->my_image_name_key__my_file_name.png
- empty imageNameKey->my_dir_name-my_file_name.png
- empty dirNameandimageNameKey->my_file_name.png
- nothing empty -> my_dir_name-__my_image_name_key__my_file_name.png
Additional context Add any other context or screenshots about the feature request here.
Excellent suggestion! When I was working on the template mechanism, I did consider the issue you raised. However, I decided to put it on hold for the time being, as it would have added complexity to the plugin and would have slowed down its completion.
At this point, I believe that it would be more practical to incorporate an existing template library, rather than trying to tweak the poor function I have created. My idea would be to use a library like Handlebars or Mustache, which offer the flexibility to add new syntax or filters to meet our needs. I will delve into this matter more deeply at a later time. Thank you for bringing this up.
note to self: probably the best solution is to add support to ejs <% var %> syntax while keep the old {{ var }} syntax working.