<script type="text/javascript" src="http://mkws.indexdata.com/mkws-complete.js"></script>
<script class="mkwsTemplate_Summary" type="text/x-handlebars-template">
<a href="#" id="{{_id}}" onclick="{{_onclick}}">
- {{#first md-thumburl}}
+ {{#mkws-first md-thumburl}}
<img src="{{this}}" alt="{{../md-title}}"/>
- {{/first}}
+ {{/mkws-first}}
<br/>
</a>
</script>
<i>{{md-title-responsibility}}</i>\
{{/if}}\
<p>\
- {{{paragraphs md-description}}}\
+ {{{mkws-paragraphs md-description}}}\
</p>\
');
});
</td>
</tr>
{{/if}}
- {{#if-any location having="md-subject"}}
+ {{#mkws-if-any location having="md-subject"}}
<tr>
<th>Subject</th>
<td>
- {{#first location having="md-subject"}}
+ {{#mkws-first location having="md-subject"}}
{{#if md-subject}}
{{md-subject}}
{{/if}}
- {{/first}}
+ {{/mkws-first}}
</td>
</tr>
- {{/if-any}}
+ {{/mkws-if-any}}
<tr>
<th>Locations</th>
<td>
- {{#commaList location}}
- {{attr "@name"}}{{/commaList}}
+ {{#mkws-commaList location}}
+ {{mkws-attr "@name"}}{{/mkws-commaList}}
</td>
</tr>
</table>
have not yet been extensively battle-tested.
0.9.2 [IN PROGRESS]
- - Full-record template invokes {{translate}} on fieldnames.
+ - Full-record template invokes {{mkws-translate}} on fieldnames.
Fixes MKWS-84 Translate fieldnames in full-record popup.
0.9.1 Thu Dec 19 15:33:13 GMT 2013
return '\
<table>\
<tr>\
- <th>{{translate "Title"}}</th>\
+ <th>{{mkws-translate "Title"}}</th>\
<td>\
{{md-title}}\
{{#if md-title-remainder}}\
</tr>\
{{#if md-date}}\
<tr>\
- <th>{{translate "Date"}}</th>\
+ <th>{{mkws-translate "Date"}}</th>\
<td>{{md-date}}</td>\
</tr>\
{{/if}}\
{{#if md-author}}\
<tr>\
- <th>{{translate "Author"}}</th>\
+ <th>{{mkws-translate "Author"}}</th>\
<td>{{md-author}}</td>\
</tr>\
{{/if}}\
{{#if md-electronic-url}}\
<tr>\
- <th>{{translate "Links"}}</th>\
+ <th>{{mkws-translate "Links"}}</th>\
<td>\
{{#each md-electronic-url}}\
- <a href="{{this}}">Link{{index1}}</a>\
+ <a href="{{this}}">Link{{mkws-index1}}</a>\
{{/each}}\
</td>\
</tr>\
{{/if}}\
- {{#if-any location having="md-subject"}}\
+ {{#mkws-if-any location having="md-subject"}}\
<tr>\
- <th>{{translate "Subject"}}</th>\
+ <th>{{mkws-translate "Subject"}}</th>\
<td>\
- {{#first location having="md-subject"}}\
+ {{#mkws-first location having="md-subject"}}\
{{#if md-subject}}\
- {{#commaList md-subject}}\
- {{this}}{{/commaList}}\
+ {{#mkws-commaList md-subject}}\
+ {{this}}{{/mkws-commaList}}\
{{/if}}\
- {{/first}}\
+ {{/mkws-first}}\
</td>\
</tr>\
- {{/if-any}}\
+ {{/mkws-if-any}}\
<tr>\
- <th>{{translate "Locations"}}</th>\
+ <th>{{mkws-translate "Locations"}}</th>\
<td>\
- {{#commaList location}}\
- {{attr "@name"}}{{/commaList}}\
+ {{#mkws-commaList location}}\
+ {{mkws-attr "@name"}}{{/mkws-commaList}}\
</td>\
</tr>\
</table>\
} else if (name === "Image") {
return '\
<a href="#" id="{{_id}}" onclick="{{_onclick}}">\
- {{#first md-thumburl}}\
+ {{#mkws-first md-thumburl}}\
<img src="{{this}}" alt="{{../md-title}}"/>\
- {{/first}}\
+ {{/mkws-first}}\
<br/>\
</a>\
';
// Handlebars helpers
-Handlebars.registerHelper('json', function(obj) {
+Handlebars.registerHelper('mkws-json', function(obj) {
return $.toJSON(obj);
});
-Handlebars.registerHelper('paragraphs', function(obj) {
+Handlebars.registerHelper('mkws-paragraphs', function(obj) {
var acc = [];
for (var i = 0; i < obj.length; i++) {
acc.push('<p>', obj[i], '</p>');
});
-Handlebars.registerHelper('translate', function(s) {
+Handlebars.registerHelper('mkws-translate', function(s) {
return mkws.M(s);
});
-// We need {{attr '@name'}} because Handlebars can't parse {{@name}}
-Handlebars.registerHelper('attr', function(attrName) {
+// We need {{mkws-attr '@name'}} because Handlebars can't parse {{@name}}
+Handlebars.registerHelper('mkws-attr', function(attrName) {
return this[attrName];
});
/*
- * Use as follows: {{#if-any NAME1 having="NAME2"}}
+ * Use as follows: {{#mkws-if-any NAME1 having="NAME2"}}
* Applicable when NAME1 is the name of an array
* The guarded code runs only if at least one element of the NAME1
* array has a subelement called NAME2.
*/
-Handlebars.registerHelper('if-any', function(items, options) {
+Handlebars.registerHelper('mkws-if-any', function(items, options) {
var having = options.hash.having;
for (var i in items) {
var item = items[i]
});
-Handlebars.registerHelper('first', function(items, options) {
+Handlebars.registerHelper('mkws-first', function(items, options) {
var having = options.hash.having;
for (var i in items) {
var item = items[i]
});
-Handlebars.registerHelper('commaList', function(items, options) {
+Handlebars.registerHelper('mkws-commaList', function(items, options) {
var out = "";
for (var i in items) {
});
-Handlebars.registerHelper('index1', function(obj) {
+Handlebars.registerHelper('mkws-index1', function(obj) {
return obj.data.index + 1;
});