Fork me on GitHub

jQuery Configurator

The jQuery plugin for injecting url parameters
into webpages and JSRender templates



Created by John Polacek

Usage

To just get a data object from the url parameters of current page, do:

var data = $.Configurator().getConfig(); // returns data object

Plays nice with JSRender because it is awesome. To use JSRender, pass in a default data object for when there are no url params, and an array of objects with targets and templates:


$.Configurator(
    { boy:'Jack', girl:'Jill', direction:'up', place:'hill' }, [
        { target:'#rhyme-form',template:'#rhyme-form-tpl' },
        { target:'#rhyme-blockquote',template:'#rhyme-blockquote-tpl' },
        { target:'#demo-url-display',template:'#demo-url-display-tpl' }]
);

If you pass in a value with commas, it will be turned into an array. For example, demo.html?people=jack,jill,bill,jim,hank,oprah gets parameterized by configurator into:

{ people:['jack','jill','bill','jim','hank','oprah'] }

We can get a lot fancier with the sorts of things you can do with jQuery Configurator, but this is enough to get started. Primarily, I use it on making prototypes and demos. You can run your own experiments on the jQuery Configurator Playground. Hopefully, I’ll have some more examples to share soon.