ptr*_*cao 7 javascript php wordpress mustache mustache.php
考虑:
<?php
/**
* Single variation display
*
* This is a javascript-based template for single variations (see https://codex.wordpress.org/Javascript_Reference/wp.template).
* The values will be dynamically replaced after selecting attributes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<script type="text/template" id="tmpl-variation-template">
<div class="woocommerce-variation-description">{{{ data.variation.variation_description }}}</div>
<div class="woocommerce-variation-price">{{{ data.variation.price_html }}}</div>
<div class="woocommerce-variation-availability">{{{ data.variation.availability_html }}}</div>
<div class="woocommerce-variation-custom-text-field">
GTIN: <span class="sku">{{{ data.variation.wccaf_gtin }}}</span>
</div>
<div class="woocommerce-variation-custom-text-field">
MPN: <span class="sku">{{{ data.variation.wccaf_mpn }}}</span>
</div>
</script>
<script type="text/template" id="tmpl-unavailable-variation-template">
<p><?php _e( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ); ?></p>
</script>
Run Code Online (Sandbox Code Playgroud)
如何实现一个条件,如IF {{{ data.variation.wccaf_gtin }}}返回空白/空值,然后回显“ GTIN不可用”?
我尝试过的
我已经在Wiki上阅读过:
带有部分标签的模板:
{{#x}}某些文本{{/ x}}在这里,当x是布尔值时,section标签的作用类似于if条件
所以我尝试了
<div class="woocommerce-variation-custom-text-field">
GTIN: <span class="sku">{{#repo}}{{ data.variation.wccaf_gtin }}{{/repo}}{{^repo}}N/A{{/repo}}</span>
</div>
Run Code Online (Sandbox Code Playgroud)
这不起作用。
但是我对胡须是完全陌生的,我需要一些指导。
这不是 Mustache 模板,正如评论指出的那样,它是 WordPress 自定义wp.template解决方案。
它没有任何逻辑标签,但有评估标签<# #>。
从快速谷歌这里有一个例子,你将如何使用它们写支票:
<# if ( data.trueValue ) { #>
<p> I am only output if <code>data.trueValue</code> is true.
<# } #>
Run Code Online (Sandbox Code Playgroud)
通过https://lkwdwrd.com/wp-template-js-templates-wp
| 归档时间: |
|
| 查看次数: |
173 次 |
| 最近记录: |