summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0560bbb)
mkws-json
mkws-paragraphs
mkws-translate
mkws-attr
mkws-if-any
mkws-first
mkws-commaList
mkws-index1
This fixes MKWS-172 ("Prefix Handlebars helpers"), which OK was only a
P5, but it irritated my sense of neatness having a P5 hanging around
in the MKWS area with all the good bugs.
<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}}">
<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}}">
+ {{#mkws-first md-thumburl}}
<img src="{{this}}" alt="{{../md-title}}"/>
<img src="{{this}}" alt="{{../md-title}}"/>
<i>{{md-title-responsibility}}</i>\
{{/if}}\
<p>\
<i>{{md-title-responsibility}}</i>\
{{/if}}\
<p>\
- {{{paragraphs md-description}}}\
+ {{{mkws-paragraphs md-description}}}\
- {{#if-any location having="md-subject"}}
+ {{#mkws-if-any location having="md-subject"}}
<tr>
<th>Subject</th>
<td>
<tr>
<th>Subject</th>
<td>
- {{#first location having="md-subject"}}
+ {{#mkws-first location having="md-subject"}}
{{#if md-subject}}
{{md-subject}}
{{/if}}
{{#if md-subject}}
{{md-subject}}
{{/if}}
<tr>
<th>Locations</th>
<td>
<tr>
<th>Locations</th>
<td>
- {{#commaList location}}
- {{attr "@name"}}{{/commaList}}
+ {{#mkws-commaList location}}
+ {{mkws-attr "@name"}}{{/mkws-commaList}}
have not yet been extensively battle-tested.
0.9.2 [IN PROGRESS]
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
Fixes MKWS-84 Translate fieldnames in full-record popup.
0.9.1 Thu Dec 19 15:33:13 GMT 2013
- <th>{{translate "Title"}}</th>\
+ <th>{{mkws-translate "Title"}}</th>\
<td>\
{{md-title}}\
{{#if md-title-remainder}}\
<td>\
{{md-title}}\
{{#if md-title-remainder}}\
</tr>\
{{#if md-date}}\
<tr>\
</tr>\
{{#if md-date}}\
<tr>\
- <th>{{translate "Date"}}</th>\
+ <th>{{mkws-translate "Date"}}</th>\
<td>{{md-date}}</td>\
</tr>\
{{/if}}\
{{#if md-author}}\
<tr>\
<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>\
<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}}\
<td>\
{{#each md-electronic-url}}\
- <a href="{{this}}">Link{{index1}}</a>\
+ <a href="{{this}}">Link{{mkws-index1}}</a>\
{{/each}}\
</td>\
</tr>\
{{/if}}\
{{/each}}\
</td>\
</tr>\
{{/if}}\
- {{#if-any location having="md-subject"}}\
+ {{#mkws-if-any location having="md-subject"}}\
- <th>{{translate "Subject"}}</th>\
+ <th>{{mkws-translate "Subject"}}</th>\
- {{#first location having="md-subject"}}\
+ {{#mkws-first location having="md-subject"}}\
- {{#commaList md-subject}}\
- {{this}}{{/commaList}}\
+ {{#mkws-commaList md-subject}}\
+ {{this}}{{/mkws-commaList}}\
- <th>{{translate "Locations"}}</th>\
+ <th>{{mkws-translate "Locations"}}</th>\
- {{#commaList location}}\
- {{attr "@name"}}{{/commaList}}\
+ {{#mkws-commaList location}}\
+ {{mkws-attr "@name"}}{{/mkws-commaList}}\
} else if (name === "Image") {
return '\
<a href="#" id="{{_id}}" onclick="{{_onclick}}">\
} else if (name === "Image") {
return '\
<a href="#" id="{{_id}}" onclick="{{_onclick}}">\
- {{#first md-thumburl}}\
+ {{#mkws-first md-thumburl}}\
<img src="{{this}}" alt="{{../md-title}}"/>\
<img src="{{this}}" alt="{{../md-title}}"/>\
-Handlebars.registerHelper('json', function(obj) {
+Handlebars.registerHelper('mkws-json', function(obj) {
return $.toJSON(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>');
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) {
-// 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];
});
/*
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.
*/
* 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]
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]
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) {
var out = "";
for (var i in items) {
-Handlebars.registerHelper('index1', function(obj) {
+Handlebars.registerHelper('mkws-index1', function(obj) {
return obj.data.index + 1;
});
return obj.data.index + 1;
});