closure-templates: Cannot read property 'assertType' of undefined when using soyutils.js on soy generated by compileToJsSrc
Take the following template :
/**
*
*/
{template .root}
{@param convention: string}
<!-- ko bindchildren: false -->
<div class="shimTimePicker">{$convention}</div>
<!-- /ko -->
{/template}
This template produce this JavaScript file output :
if (typeof eca == 'undefined') { var eca = {}; }
if (typeof eca.templates == 'undefined') { eca.templates = {}; }
if (typeof eca.templates.timepicker == 'undefined') { eca.templates.timepicker = {}; }
eca.templates.timepicker.root = function(opt_data, opt_ignored, opt_ijData) {
soy.asserts.assertType(goog.isString(opt_data.convention) || (opt_data.convention instanceof goog.soy.data.SanitizedContent), 'convention', opt_data.convention, 'string|goog.soy.data.SanitizedContent');
var convention = /** @type {string|goog.soy.data.SanitizedContent} */ (opt_data.convention);
return soydata.VERY_UNSAFE.ordainSanitizedHtml('<!-- ko bindchildren: false --><div class="timepicker hidden' + ((convention != 'oc_na') ? ' notam' : '') + '" data-bind="css: {hidden: !visible()}"><div data-bind="foreach: times"><div class="row" data-bind="click:$parent.select, class:classes"><div class="container"><div class="time"><!-- ko ifnot: $parent.delcol() --><span data-bind="text:displayHour()"></span>:<span data-bind="text:displayMinute()"></span> <span data-bind="text:ampm"></span><!-- /ko --><!-- ko if: $parent.delcol() --><span data-bind="text: delcolTimeSlotDisplay"></span><!-- /ko --></div><div class="info" data-bind="text:info"></div><div class="spacer"></div></div></div></div></div><div class="shimTimePicker"></div><!-- /ko -->');
};
if (goog.DEBUG) {
eca.templates.timepicker.root.soyTemplateName = 'eca.templates.timepicker.root';
}
But I am getting this error : Cannot read property ‘assertType’ of undefined
I am using the soy-2016-08-25 Maven dependency and the latest version of closure-templates-for-javascript via :
soyutils.js
In soyutils.js I cannot find this function :
soy.asserts.assertType(...)
Also I am using jQuery 1.7.2 and latest version of KnockoutJS.
Please could you help me with this ? What I am doing wrong ?
Remarks : I am trying to move from the first version of closure template ‘1.0’ to the latest. I have no errors in my Java side.
On the Java side, here is my code to generate Js from Soy File :
final SoyFileSet soyFileSet = SoyFileSet.builder().add(preparedContent, resource.getName()).add(commonPrepared, common.getName()).build();
if ("soy".equals(type)) {
tofus.put(tofuKey, new SoyTofuOrJavaScript(soyFileSet.compileToTofu()));
} else if ("js".equals(type)) {
final SoyJsSrcOptions jsOpt = new SoyJsSrcOptions();
tofus.put(tofuKey, new SoyTofuOrJavaScript(Joiner.on(';').join(soyFileSet.compileToJsSrc(jsOpt, null))));
}
And to render it :
if (Arrays.asList(NEED_CONTENTKIND_JS).contains(templateName)) {
return renderer.setData(data).setContentKind(ContentKind.JS).render();
} else {
return renderer.setData(data).render();
}
Thank you very much. Best regards.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 22 (5 by maintainers)
Hi @mikesamuel , @lukesandberg
Any updates would be very appreciated.
Thanks!