start: 5, // seconds
end: 10, // seconds
target: 'mustache-div',
- template: "<h1>{{header}}</h1>" +
- "{{#items}}" +
- " {{#first}}" +
- " <li><strong>{{name}}</strong></li>" +
- " {{/first}}" +
- " {{#link}}" +
- ' <li><a href="{{url}}">{{name}}</a></li>' +
- " {{/link}}" +
- "{{/items}}" +
- "" +
- "{{#empty}}" +
- " <p>The list is empty.</p>" +
- "{{/empty}}" ,
+ template: '<h1>{{header}}</h1>' +
+ '{{#items}}' +
+ ' {{#first}}' +
+ ' <li><strong>{{name}}</strong></li>' +
+ ' {{/first}}' +
+ ' {{#link}}' +
+ ' <li><a href="{{url}}">{{name}}</a></li>' +
+ ' {{/link}}' +
+ '{{/items}}' +
+ ' +
+ '{{#empty}}' +
+ ' <p>The list is empty.</p>' +
+ '{{/empty}}' ,
data: '{' +
' "header": "Test 1", ' +
end: 20,
target: 'mustache-div',
template: function(plugin, options) {
- return "<h1>{{header}}</h1>" +
- "{{#items}}" +
- " {{#first}}" +
- " <li><strong>{{name}}</strong></li>" +
- " {{/first}}" +
- " {{#link}}" +
+ return '<h1>{{header}}</h1>' +
+ '{{#items}}' +
+ ' {{#first}}' +
+ ' <li><strong>{{name}}</strong></li>' +
+ ' {{/first}}' +
+ ' {{#link}}' +
' <li><a href="{{url}}">{{name}}</a></li>' +
- " {{/link}}" +
- "{{/items}}" +
- "" +
- "{{#empty}}" +
- " <p>The list is empty.</p>" +
- "{{/empty}}" ;
+ ' {{/link}}' +
+ '{{/items}}' +
+ '' +
+ '{{#empty}}' +
+ ' <p>The list is empty.</p>' +
+ '{{/empty}}' ;
},
data: {
- header: "Test 2",
+ header: 'Test 2',
items: [
- { name: "red", first: true, url: "#Red" },
- { name: "green", link: true, url: "#Green" },
- { name: "blue", link: true, url: "#Blue"}
+ { name: 'red', first: true, url: '#Red' },
+ { name: 'green', link: true, url: '#Green' },
+ { name: 'blue', link: true, url: '#Blue'}
],
empty: false
}
end: 30,
target: 'mustache-div',
template: function(plugin, options) {
- return "<h1>{{header}}</h1>" +
- "{{#items}}" +
- " {{#first}}" +
- " <li><strong>{{name}}</strong></li>" +
- " {{/first}}" +
- " {{#link}}" +
+ return '<h1>{{header}}</h1>' +
+ '{{#items}}' +
+ ' {{#first}}' +
+ ' <li><strong>{{name}}</strong></li>' +
+ ' {{/first}}' +
+ ' {{#link}}' +
' <li><a href="{{url}}">{{name}}</a></li>' +
- " {{/link}}" +
- "{{/items}}" +
- "" +
- "{{#empty}}" +
- " <p>The list is empty.</p>" +
- "{{/empty}}" ;
+ ' {{/link}}' +
+ '{{/items}}' +
+ '' +
+ '{{#empty}}' +
+ ' <p>The list is empty.</p>' +
+ '{{/empty}}' ;
},
data: function(plugin, options) {
return JSON.parse('' +
// TODO: swap to getScript()
(function() {
- var mustacheUrl = "https://github.com/janl/mustache.js/raw/master/mustache.js";
+ var mustacheUrl = 'https://github.com/janl/mustache.js/raw/master/mustache.js';
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
- script.type = "text/javascript";
+ script.type = 'text/javascript';
script.src = mustacheUrl;
head.insertBefore( script, head.firstChild );
})();
start: 5, // seconds
end: 15, // seconds
target: 'mustache',
- template: "<h1>{{header}}</h1>" +
- "{{#bug}}" +
- "{{/bug}}" +
- "" +
- "{{#items}}" +
- " {{#first}}" +
- " <li><strong>{{name}}</strong></li>" +
- " {{/first}}" +
- " {{#link}}" +
+ template: '<h1>{{header}}</h1>' +
+ '{{#bug}}' +
+ '{{/bug}}' +
+ '' +
+ '{{#items}}' +
+ ' {{#first}}' +
+ ' <li><strong>{{name}}</strong></li>' +
+ ' {{/first}}' +
+ ' {{#link}}' +
' <li><a href="{{url}}">{{name}}</a></li>' +
- " {{/link}}" +
- "{{/items}}" +
- "" +
- "{{#empty}}" +
- " <p>The list is empty.</p>" +
- "{{/empty}}" ,
+ ' {{/link}}' +
+ '{{/items}}' +
+ '' +
+ '{{#empty}}' +
+ ' <p>The list is empty.</p>' +
+ '{{/empty}}' ,
data: '{' +
' "header": "Colors", ' +
' {"name": "green", "link": true, "url": "#Green"}, ' +
' {"name": "blue", "link": true, "url": "#Blue"} ' +
' ],' +
- ' "empty": false' +
+ ' 'empty': false' +
'}',
dynamic: false // The json is not going to change, load it early.
} )
*
*/
- Popcorn.plugin( "mustache" , function() {
+ Popcorn.plugin( 'mustache' , function() {
function get( name, options ) {
return options._instance[name];
return {
manifest: {
about: {
- name: "Popcorn Mustache Plugin",
- version: "0.1",
- author: "David Humphrey (@humphd)",
- website: "http://vocamus.net/dave"
+ name: 'Popcorn Mustache Plugin',
+ version: '0.1',
+ author: 'David Humphrey (@humphd)',
+ website: 'http://vocamus.net/dave'
},
options: {
start: {elem:'input', type:'text', label:'In'},
} else if ( typeOfTemplate === 'string' ) {
set( 'template', options, options.template );
} else {
- throw "Mustache Plugin Error: options.template must be a String or a Function.";
+ throw 'Mustache Plugin Error: options.template must be a String or a Function.';
}
if ( typeOfData === 'function' ) {
} else if ( typeOfData === 'object' ) {
set( 'data', options, options.data );
} else {
- throw "Mustache Plugin Error: options.data must be a String, Object, or Function.";
+ throw 'Mustache Plugin Error: options.data must be a String, Object, or Function.';
}
},
-test("Popcorn Mustache Plugin", function () {
+test('Popcorn Mustache Plugin', function () {
- var popped = Popcorn("#video"),
+ var popped = Popcorn('#video'),
expects = 5,
count = 0,
mustacheDiv = document.getElementById('mustache-div');
stop();
- ok('mustache' in popped, "mustache is a method of the popped instance");
+ ok('mustache' in popped, 'mustache is a method of the popped instance');
plus();
- equals ( mustacheDiv.innerHTML, "", "initially, there is nothing inside the mustache-div" );
+ equals ( mustacheDiv.innerHTML, '', 'initially, there is nothing inside the mustache-div' );
plus();
// Static strings
popped.mustache({
start: 1, // seconds
end: 3, // seconds
- template: "<h1>{{heading}}</h1>",
+ template: '<h1>{{heading}}</h1>',
data: '{"heading": "mustache - test 1/3"}',
target: 'mustache-div',
dynamic: false
start: 5, // seconds
end: 7, // seconds
template: function(plugin, options) {
- return "<h1>{{heading}}</h1>";
+ return '<h1>{{heading}}</h1>';
},
data: function(plugin, options) {
return JSON.parse('{"heading": "mustache - test 2/3"}');
start: 9, // seconds
end: 11, // seconds
template: function(plugin, options) {
- return "<h1>{{heading}}</h1>";
+ return '<h1>{{heading}}</h1>';
},
- data: { heading: "mustache - test 3/3" },
+ data: { heading: 'mustache - test 3/3' },
target: 'mustache-div',
dynamic: false
} );
video.addEventListener('timeupdate', function() {
function pass(a, b) {
- ok( "<h1>mustache - test " + a + "/" + b + "<\/h1>" === mustacheDiv.innerHTML, "Mustache template rendered" );
+ equals( '<h1>mustache - test ' + a + '/' + b + '<\/h1>', mustacheDiv.innerHTML, 'Mustache template rendered' );
plus();
}