Use partials
This commit is contained in:
parent
149e22baac
commit
a8c7a8602f
@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
handlebars -m util/tmpl/* -f ext/bg/templates.js
|
handlebars util/tmpl/* -f ext/bg/templates.js
|
||||||
|
@ -1 +1,35 @@
|
|||||||
!function(){var n=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["defs.html"]=n({1:function(n,a,e,l,s){var i,r,o=null!=a?a:{},d=e.helperMissing,t="function",c=n.escapeExpression;return'<div class="yomichan-def">\n <div class="yomichan-def-expression">'+c((r=null!=(r=e.expression||(null!=a?a.expression:a))?r:d,typeof r===t?r.call(o,{name:"expression",hash:{},data:s}):r))+"</div>\n"+(null!=(i=e["if"].call(o,null!=a?a.reading:a,{name:"if",hash:{},fn:n.program(2,s,0),inverse:n.noop,data:s}))?i:"")+' <div class="yomichan-def-glossary">'+c((r=null!=(r=e.glossary||(null!=a?a.glossary:a))?r:d,typeof r===t?r.call(o,{name:"glossary",hash:{},data:s}):r))+"</div>\n</div>\n"},2:function(n,a,e,l,s){var i;return' <div class="yomichan-def-reading">'+n.escapeExpression((i=null!=(i=e.reading||(null!=a?a.reading:a))?i:e.helperMissing,"function"==typeof i?i.call(null!=a?a:{},{name:"reading",hash:{},data:s}):i))+"</div>\n"},compiler:[7,">= 4.0.0"],main:function(n,a,e,l,s){var i;return null!=(i=e.each.call(null!=a?a:{},null!=a?a.defs:a,{name:"each",hash:{},fn:n.program(1,s,0),inverse:n.noop,data:s}))?i:""},useData:!0})}();
|
(function() {
|
||||||
|
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
||||||
|
templates['defs.html'] = template({"1":function(container,depth0,helpers,partials,data) {
|
||||||
|
var stack1;
|
||||||
|
|
||||||
|
return "<div class=\"yomichan-def\">\n"
|
||||||
|
+ ((stack1 = container.invokePartial(partials["term.html"],depth0,{"name":"term.html","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
|
||||||
|
+ " "
|
||||||
|
+ ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.last),{"name":"unless","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
||||||
|
+ "\n</div>\n";
|
||||||
|
},"2":function(container,depth0,helpers,partials,data) {
|
||||||
|
return "<br>";
|
||||||
|
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
||||||
|
var stack1;
|
||||||
|
|
||||||
|
return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.defs : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
|
||||||
|
},"usePartial":true,"useData":true});
|
||||||
|
templates['term.html'] = template({"1":function(container,depth0,helpers,partials,data) {
|
||||||
|
var helper;
|
||||||
|
|
||||||
|
return "<div class=\"yomichan-def-reading\">"
|
||||||
|
+ container.escapeExpression(((helper = (helper = helpers.reading || (depth0 != null ? depth0.reading : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"reading","hash":{},"data":data}) : helper)))
|
||||||
|
+ "</div>";
|
||||||
|
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
|
||||||
|
var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
|
||||||
|
|
||||||
|
return "<div class=\"yomichan-def-expression\">"
|
||||||
|
+ alias4(((helper = (helper = helpers.expression || (depth0 != null ? depth0.expression : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"expression","hash":{},"data":data}) : helper)))
|
||||||
|
+ "</div>\n"
|
||||||
|
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reading : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
||||||
|
+ "\n<div class=\"yomichan-def-glossary\">"
|
||||||
|
+ alias4(((helper = (helper = helpers.glossary || (depth0 != null ? depth0.glossary : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"glossary","hash":{},"data":data}) : helper)))
|
||||||
|
+ "</div>\n";
|
||||||
|
},"useData":true});
|
||||||
|
})();
|
@ -31,6 +31,8 @@ class Yomichan {
|
|||||||
|
|
||||||
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
|
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
|
||||||
chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this));
|
chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this));
|
||||||
|
|
||||||
|
Handlebars.partials = Handlebars.templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessage(request, sender, callback) {
|
onMessage(request, sender, callback) {
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
{{#each defs}}
|
{{#each defs}}
|
||||||
<div class="yomichan-def">
|
<div class="yomichan-def">
|
||||||
<div class="yomichan-def-expression">{{expression}}</div>
|
{{> term.html}}
|
||||||
{{#if reading}}
|
{{#unless @last}}<br>{{/unless}}
|
||||||
<div class="yomichan-def-reading">{{reading}}</div>
|
|
||||||
{{/if}}
|
|
||||||
<div class="yomichan-def-glossary">{{glossary}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
3
util/tmpl/term.html
Normal file
3
util/tmpl/term.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<div class="yomichan-def-expression">{{expression}}</div>
|
||||||
|
{{#if reading}}<div class="yomichan-def-reading">{{reading}}</div>{{/if}}
|
||||||
|
<div class="yomichan-def-glossary">{{glossary}}</div>
|
Loading…
Reference in New Issue
Block a user