RwSetGet — jsPathto Revisited

Quite some time ago I wrote a simple JavaScript tool for RapidWeaver theme developers called jsPathto to parse RapidWeaver’s %pathto()% syntax for use in any JavaScript file. It’s been widely used in RapidWeaver themes, especially ours, and it works quite well. However, if you’re not the guy who wrote the script it can sometimes take a bit to wrap your head around it and get it working correctly for you.

At the urging of Gary from RWT I recently revisited the jsPathto idea and came up with RwSetGet, an open source set of JavaScript object literals hosted on github that when used, will allow RapidWeaver theme developers to obtain, use and even extend both the %pathto()% and %base_url% syntax in RapidWeaver. The best part is, it’s dead simple to use and nearly fool proof.

So what would RapidWeaver developers use RwSetGet for? Well anyone already using jsPathto would already be aware of the benefits and immediately see the wider range of possibilities available with RwSetGet. But for those who’ve never ventured into dynamic theme features with jsPathto may not at first understand why they would ever need it. Truth be told, if you haven’t needed it yet then you likely won’t care about this tool but here is what it’s for…

Say a script in your theme is testing a users style selection and based on that selection it will load another suitable script file to perform the appropriate function for the selected style. Or perhaps you need to load the data from a particular JSON file in accordance with that users selection.

A perfect example is the built in slide shows in our own themes. These slide shows currently make heavy use of jsPathto and would not be possible without it. A user selects a range of images they want in their slide show, the effect they want, the transition speed, the duration… all of this data is collected and the appropriate files fetched with the help of jsPathto. With RwSetGet I hope to expand the capabilities of these slide shows even further.

So if you’ve ever found yourself wishing you could use %pathto()% in your JavaScript files, RwSetGet is the tool for you.

Check out RwSetGet on github.

Comments are closed.