My apologies if you've tried this already - I'm new to javascript and am still learning. I have added a couple of new commands at the bottom of your template file and am able to save a variable to localstorage, and then read the value from local storage.
To test, I used the template.html and at the start, I saved a variable and reset the value, and in a later part of the template I echo'd the current value, restored it, and echo'd the new value.
I am going to see if I can incorporate into a simple game to test some more but I thought I'd share.
You've really done a great job at making it simple to create a game.
commands["save"] = function (name, value) {
localStorage.setItem(name, value);
return "";
};
commands["restore"] = function (name) {
value = ( localStorage.getItem(name) );
variables[name] = value;
return "";
};