From b9addc8428c8cabe0be7ecdfffa6488a148757c5 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 26 Jan 2017 22:38:59 -0800 Subject: [PATCH] template work --- ext/bg/js/templates.js | 86 +++++++++++++++++------------------------- tmpl/fields.html | 44 +++++++++++---------- 2 files changed, 58 insertions(+), 72 deletions(-) diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index 75429e24..543d4c04 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -37,9 +37,9 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti },"3":function(container,depth0,helpers,partials,data) { var stack1; - return "
(" + return "(" + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ")
"; + + ") "; },"4":function(container,depth0,helpers,partials,data) { var stack1, helper, alias1=depth0 != null ? depth0 : {}; @@ -63,12 +63,12 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti },"9":function(container,depth0,helpers,partials,data) { return container.escapeExpression(container.lambda(depth0, depth0)); },"11":function(container,depth0,helpers,partials,data) { - var stack1, helper, options, buffer = - "
"; + var stack1, helper, options, buffer = ""; + stack1 = ((helper = (helper = helpers.multiLine || (depth0 != null ? depth0.multiLine : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"multiLine","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},options) : helper)); if (!helpers.multiLine) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { buffer += stack1; } - return buffer + "
"; + return buffer; },"12":function(container,depth0,helpers,partials,data) { var stack1; @@ -83,7 +83,7 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti return "(" + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ")"; + + ") "; },"17":function(container,depth0,helpers,partials,data) { var stack1; @@ -98,21 +98,15 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti },"22":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.character : stack1), depth0)) - + "\n"; + return container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.character : stack1), depth0)); },"24":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.dictionary : stack1), depth0)) - + "\n"; + return container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.dictionary : stack1), depth0)); },"26":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.modeTermKana : depth0),{"name":"if","hash":{},"fn":container.program(27, data, 0),"inverse":container.program(30, data, 0),"data":data})) != null ? stack1 : "") - + "\n"; + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.modeTermKana : depth0),{"name":"if","hash":{},"fn":container.program(27, data, 0),"inverse":container.program(30, data, 0),"data":data})) != null ? stack1 : ""); },"27":function(container,depth0,helpers,partials,data) { var stack1; @@ -152,89 +146,77 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti + " [" + alias2(alias1(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.reading : stack1), depth0)) + "]"; -},"39":function(container,depth0,helpers,partials,data) { +},"39":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1, alias1=depth0 != null ? depth0 : {}; - return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(40, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.group : depth0),{"name":"if","hash":{},"fn":container.program(42, data, 0),"inverse":container.program(52, data, 0),"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(54, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); + return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(40, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.group : depth0),{"name":"if","hash":{},"fn":container.program(42, data, 0, blockParams, depths),"inverse":container.program(52, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(54, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); },"40":function(container,depth0,helpers,partials,data) { return "
"; -},"42":function(container,depth0,helpers,partials,data) { +},"42":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(43, data, 0),"inverse":container.program(50, data, 0),"data":data})) != null ? stack1 : ""); -},"43":function(container,depth0,helpers,partials,data) { + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(43, data, 0, blockParams, depths),"inverse":container.program(50, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); +},"43":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(44, data, 0),"inverse":container.program(47, data, 0),"data":data})) != null ? stack1 : ""); -},"44":function(container,depth0,helpers,partials,data) { + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(44, data, 0, blockParams, depths),"inverse":container.program(47, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); +},"44":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return "
    " - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1),{"name":"each","hash":{},"fn":container.program(45, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1),{"name":"each","hash":{},"fn":container.program(45, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "
"; -},"45":function(container,depth0,helpers,partials,data) { +},"45":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return "
  • " - + ((stack1 = container.invokePartial(partials["glossary-single"],depth0,{"name":"glossary-single","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + + ((stack1 = container.invokePartial(partials["glossary-single"],depth0,{"name":"glossary-single","hash":{"html":(depths[1] != null ? depths[1].html : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + "
  • "; -},"47":function(container,depth0,helpers,partials,data) { +},"47":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1),{"name":"each","hash":{},"fn":container.program(48, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"48":function(container,depth0,helpers,partials,data) { + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1),{"name":"each","hash":{},"fn":container.program(48, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"48":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return "* " - + ((stack1 = container.invokePartial(partials["glossary-single"],depth0,{"name":"glossary-single","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); + return " * " + + ((stack1 = container.invokePartial(partials["glossary-single"],depth0,{"name":"glossary-single","hash":{"html":(depths[1] != null ? depths[1].html : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); },"50":function(container,depth0,helpers,partials,data) { var stack1; - return ((stack1 = container.invokePartial(partials["glossary-single"],((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1)) != null ? stack1["0"] : stack1),{"name":"glossary-single","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); + return ((stack1 = container.invokePartial(partials["glossary-single"],((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.definitions : stack1)) != null ? stack1["0"] : stack1),{"name":"glossary-single","hash":{"html":(depth0 != null ? depth0.html : depth0)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); },"52":function(container,depth0,helpers,partials,data) { var stack1; - return ((stack1 = container.invokePartial(partials["glossary-single"],(depth0 != null ? depth0.definition : depth0),{"name":"glossary-single","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); + return ((stack1 = container.invokePartial(partials["glossary-single"],(depth0 != null ? depth0.definition : depth0),{"name":"glossary-single","hash":{"html":(depth0 != null ? depth0.html : depth0)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); },"54":function(container,depth0,helpers,partials,data) { return "
    "; },"56":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.kunyomi : stack1),{"name":"each","hash":{},"fn":container.program(18, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n"; + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.kunyomi : stack1),{"name":"each","hash":{},"fn":container.program(18, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); },"58":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.onyomi : stack1),{"name":"each","hash":{},"fn":container.program(18, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n"; + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.onyomi : stack1),{"name":"each","hash":{},"fn":container.program(18, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); },"60":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.modeTermKana : depth0),{"name":"unless","hash":{},"fn":container.program(28, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n"; + return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.modeTermKana : depth0),{"name":"unless","hash":{},"fn":container.program(28, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); },"62":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.sentence : stack1), depth0)) - + "\n"; + return container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.sentence : stack1), depth0)); },"64":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.tags : stack1),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n"; + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.tags : stack1),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); },"66":function(container,depth0,helpers,partials,data) { var stack1; - return " " - + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(67, data, 0),"inverse":container.program(69, data, 0),"data":data})) != null ? stack1 : "") - + "\n"; + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(67, data, 0),"inverse":container.program(69, data, 0),"data":data})) != null ? stack1 : ""); },"67":function(container,depth0,helpers,partials,data) { var stack1, alias1=container.lambda, alias2=container.escapeExpression; diff --git a/tmpl/fields.html b/tmpl/fields.html index 8eead5ce..0e96828e 100644 --- a/tmpl/fields.html +++ b/tmpl/fields.html @@ -1,17 +1,13 @@ {{#*inline "glossary-single"}} {{~#if html~}} - {{~#if tags~}} -
    ({{#each tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}})
    - {{~/if~}} + {{~#if tags~}}({{#each tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}}) {{/if~}} {{~#if glossary.[1]~}} {{~else~}} -
    {{#multiLine}}{{glossary.[0]}}{{/multiLine}}
    + {{~#multiLine}}{{glossary.[0]}}{{/multiLine~}} {{~/if~}} {{~else~}} - {{~#if tags~}} - ({{#each tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}}) - {{~/if~}} + {{~#if tags~}}({{#each tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}}) {{/if~}} {{~#if glossary.[1]~}} {{#each glossary}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} {{~else~}} @@ -23,15 +19,23 @@ {{#*inline "audio"}}{{/inline}} {{#*inline "character"}} - {{definition.character}} + {{~definition.character~}} {{/inline}} {{#*inline "dictionary"}} - {{definition.dictionary}} + {{~definition.dictionary~}} {{/inline}} {{#*inline "expression"}} - {{#if modeTermKana}}{{#if definition.reading}}{{definition.reading}}{{else}}{{definition.expression}}{{/if}}{{else}}{{definition.expression}}{{/if}} + {{~#if modeTermKana~}} + {{~#if definition.reading~}} + {{definition.reading}} + {{~else~}} + {{definition.expression}} + {{~/if~}} + {{~else~}} + {{definition.expression}} + {{~/if~}} {{/inline}} {{#*inline "furigana"}} @@ -46,39 +50,39 @@ {{~#if html}}
    {{/if~}} {{~#if group~}} {{~#if definition.definitions.[1]~}} - {{~#if html}}
      {{#each definition.definitions}}
    1. {{> glossary-single}}
    2. {{/each}}
    - {{~else}}{{#each definition.definitions}}* {{> glossary-single}}{{/each}}{{/if~}} + {{~#if html}}
      {{#each definition.definitions}}
    1. {{> glossary-single html=../html}}
    2. {{/each}}
    + {{~else}}{{#each definition.definitions}} * {{> glossary-single html=../html}}{{/each}}{{/if~}} {{~else~}} - {{> glossary-single definition.definitions.[0]}} + {{~> glossary-single definition.definitions.[0] html=html~}} {{~/if~}} {{~else~}} - {{> glossary-single definition}} + {{~> glossary-single definition html=html~}} {{~/if~}} {{~#if html}}
    {{/if~}} {{/inline}} {{#*inline "kunyomi"}} - {{#each definition.kunyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} + {{~#each definition.kunyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}} {{/inline}} {{#*inline "onyomi"}} - {{#each definition.onyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each}} + {{~#each definition.onyomi}}{{.}}{{#unless @last}}, {{/unless}}{{/each~}} {{/inline}} {{#*inline "reading"}} - {{#unless modeTermKana}}{{definition.reading}}{{/unless}} + {{~#unless modeTermKana}}{{definition.reading}}{{/unless~}} {{/inline}} {{#*inline "sentence"}} - {{definition.sentence}} + {{~definition.sentence~}} {{/inline}} {{#*inline "tags"}} - {{#each definition.tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each}} + {{~#each definition.tags}}{{name}}{{#unless @last}}, {{/unless}}{{/each~}} {{/inline}} {{#*inline "url"}} - {{#if html}}{{definition.url}}{{else}}{{definition.url}}{{/if}} + {{~#if html}}{{definition.url}}{{else}}{{definition.url}}{{/if~}} {{/inline}} {{~> (lookup . "marker") ~}}