Rubberband demo

Demonstrtes how LiveTemplate works with replacements, events, and serialization

by Dan Stocker

HTML

<script src="https://dl.dropboxusercontent.com/u/9258903/JavaScript/dessert-0.3.2-min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/9258903/JavaScript/troop-0.8.0-min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/9258903/JavaScript/sntls-0.19.0-min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/9258903/JavaScript/evan-0.7.2-min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/9258903/JavaScript/rubberband-0.1.2-min.js"></script>

JavaScript

// creating template with parameters
var template = "Today is {{formatted day of the week}}.".toLiveTemplate()
    .addReplacements({
    '{{formatted day of the week}}': "<em>{{day of the week}}</em>"
});

template.subscribeTo(rubberband.LiveTemplate.EVENT_TEMPLATE_REPLACEMENTS_CHANGE, function (event) {
    $('body').append("replacements changed, new string: " + event.sender + '<br />');
});

// will trigger event and log to the console
template.addReplacements({
    '{{day of the week}}': "Tuesday"
});

template.addReplacements({
    '{{day of the week}}': "Friday"
});

template.clearReplacements();