Попробуйте то же самое, используя ints-jst
Код:
<div id="try-jst">
<div class="woocommerce-variation-description">
<js-t> print(data.variation.variation_description);</js-t>
</div>
<div class="woocommerce-variation-price">
<js-t> print(data.variation.price_html);</js-t>
</div>
<div class="woocommerce-variation-availability">
<js-t> print(data.variation.availability_html);</js-t>
</div>
<div class="woocommerce-variation-custom-text-field">
GTIN:
<span class="sku">
<js-t>
if(!!data.variation.wccaf_gtin) {
print(data.variation.wccaf_gtin);
} else {
print("unavailable");
}
</js-t>
</span>
</div>
<div class="woocommerce-variation-custom-text-field">
MPN:
<span class="sku">
<js-t>
if(!!data.variation.wccaf_mpn) {
print(data.variation.wccaf_mpn);
} else {
print("unavailable");
}
</js-t>
</span>
</div>
</div>
Сценарий:
<script>
/* var data = {
variation: {
variation_description: 'variation_description',
price_html: 'price_html',
availability_html: 'availability_html',
wccaf_gtin: '',
wccaf_mpn: '123',
}
}; */
// jQuery version
compile($('#try-jst')[0]);
run();
// Plain Javascript
/**
* compile(document.getElementById('try-jst'));
* run();
*/
</script>
Вывод:
<div id="try-jst">
<div class="woocommerce-variation-description">variation_description</div>
<div class="woocommerce-variation-price">price_html</div>
<div class="woocommerce-variation-availability">availability_html</div>
<div class="woocommerce-variation-custom-text-field"> GTIN: <span class="sku">unavailable</span></div>
<div class="woocommerce-variation-custom-text-field"> MPN: <span class="sku">123</span></div>
</div>
Так что вы можете попробовать.