Render hashtags using labels
Use labels to represent #hashtags in the HTML rendering. Allows commands like "#swift now discussing #cinder" to render with two labels.
This commit is contained in:
parent
173c3ba5c4
commit
b8ca0c43ff
@ -23,7 +23,7 @@
|
|||||||
{{#each now}}
|
{{#each now}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="col-sm-1"><span class="label label-primary">{{@key}}</span></td>
|
<td class="col-sm-1"><span class="label label-primary">{{@key}}</span></td>
|
||||||
<td>{{this}}</td>
|
<td>{{#hashtag}}{{this}}{{/hashtag}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr><td><small><i>Nothing yet</i></small><td></tr>
|
<tr><td><small><i>Nothing yet</i></small><td></tr>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<td class="col-sm-1"><span class="label label-primary">{{room}}</span></td>
|
<td class="col-sm-1"><span class="label label-primary">{{room}}</span></td>
|
||||||
<td>
|
<td>
|
||||||
{{#each sessions}}
|
{{#each sessions}}
|
||||||
{{ this }}<br/>
|
{{#hashtag}}{{this}}{{/hashtag}}<br/>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
{{#each ethercalc}}
|
{{#each ethercalc}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{this}}</td>
|
<td>{{#hashtag}}{{this}}{{/hashtag}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr><td><small><i>Nothing yet</i></small><td></tr>
|
<tr><td><small><i>Nothing yet</i></small><td></tr>
|
||||||
|
14
html/ptg.js
14
html/ptg.js
@ -4,6 +4,20 @@ var source = document.getElementById("PTGtemplate").innerHTML;
|
|||||||
// Handlebars compiles the above source into a template
|
// Handlebars compiles the above source into a template
|
||||||
var template = Handlebars.compile(source);
|
var template = Handlebars.compile(source);
|
||||||
|
|
||||||
|
Handlebars.registerHelper('hashtag', function(options) {
|
||||||
|
var words = options.fn(this).split(" ");
|
||||||
|
var sentence = "";
|
||||||
|
for (var i = 0; i < words.length; i++) {
|
||||||
|
if (words[i].startsWith("#")) {
|
||||||
|
sentence += '<span class="label label-info">'
|
||||||
|
+ words[i].substring(1) + '</span> ';
|
||||||
|
} else {
|
||||||
|
sentence += words[i] + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Handlebars.SafeString(sentence);
|
||||||
|
});
|
||||||
|
|
||||||
$.getJSON("ptg.json", function(json) {
|
$.getJSON("ptg.json", function(json) {
|
||||||
console.log(json);
|
console.log(json);
|
||||||
document.getElementById("PTGsessions").innerHTML = template(json);
|
document.getElementById("PTGsessions").innerHTML = template(json);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user