Custom properties with scripts made easy
If you do custom properties in my experience they often include some java scripting to accomplish what you want.
I sure have done my fair share of massive one liners that’s hard to maintain and if you touch them after 11pm you’re going to break them.
Splitting the scripts on several rows is more readable but messes up your code with endless lines of string concatenation.
So what to do? Virtual path providers and embedded resources is the solution.
Allan Thraen has done an excellent job with a single assembly self registrating virtual path provider which you can get here. It’s compiled for CMS5 but it works for CMS6 as well.
With this it’s a breeze to use embedded resources.
Now we have a nice place where we can place all our scripts nicely formatted and commented.
To read the script file contents you can use the following method. The only thing needed to change is the virtualpath variable which should should point to your resource. If unsure of the path check it out with reflector.