timo-reymann / intellij-mjml-support

MJML support for the IntelliJ Platform.
https://timo-reymann.github.io/intellij-mjml-support/
Other
26 stars 11 forks source link

Support projet local paths for renderScriptPath #223

Open EdwardSalter opened 20 hours ago

EdwardSalter commented 20 hours ago

Description

I have a custom renderer script implemented in my repository to allow for supporting templating in my MJML files. When I set this renderer through the settings UI, the .idea\mjmlSettings.xml file gets created with the renderScriptPath property set to the full file path of my custom renderer (e.g. <option name="renderScriptPath" value="W:\MyRepo\scripts\intellij_mjml_renderer.js" />).

Many other xml files in the .idea directory support the use of the $PROJECT_DIR$ replacement variable that can be used instead of a full file path (e.g. <option name="renderScriptPath" value="$PROJCET_DIR$\scripts\intellij_mjml_renderer.js" />). If this plugin supported that same replacement, the mjmlSettings.xml file could be checked in to source control so that the plugin can be automatically configured when sharing between different machines/developers where repositories will not always have the same paths.

References

No response

timo-reymann commented 9 hours ago

I took a look at this, and it should be working out of the box, as the serialize/deserialize logic from JetBrains replaces the path variables in saved configuration files accordingly.

After digging a bit in JetBrains forums, I found this from 2016:

I didn't notice that IDEA collapse paths on save automatically.

My fault was to use system dependent separator (in my case '\') Because collapse & expand only works with '/' but not with '\'.

I tested it on my Ubuntu machines & Macbook, and it works fine on all of them.

So I assume it's the same issue here. Currently, I set the path as is, which apparently seems to be an issue on Windows systems.

EdwardSalter commented 8 hours ago

Thank you for looking at this so quickly!

I did try to manually modify the settings file to include some path variables before I submitted the issue but I was trying with the backslash paths. I've just tried it again now using forward slash paths and found that it is indeed correctly replacing the values meaning that I can commmit my settings file to the repository.

timo-reymann commented 8 hours ago

Awesome, will merge that one to main.

I would just kindly ask you to install the snapshot (ci will post the link) and try if the fix works well on Windows. I dont really have a Windows dev machine I could test it on 😅

timo-reymann commented 7 hours ago

Comment did not work due to autoclose by referencing in MR 😅

You can download it here: https://plugins.jetbrains.com/plugin/download?rel=true&updateId=636483