gpt4 book ai didi

javascript - 不存在的 Smarty 错误?

转载 作者:行者123 更新时间:2023-11-29 10:59:27 25 4
gpt4 key购买 nike

我遇到了一个基本上不存在的错误,或者我 super 盲目,因为我已经花了最后 30 分钟解决这个问题。

<b>Fatal error</b>:  Uncaught  --&gt; Smarty Compiler: Syntax error in template &quot;file:C:\htdocs\smarty\templates\shopify_apps\bundle\js_modules\product_reviews.tpl&quot;  on line 30 &quot;$('head').append('&lt;style&gt; .ratings {position: relative !important;vertical-align: middle!important;display: inline-block!important;color: #b1b1b1!important; overflow: hidden!important;}.full-stars {position: absolute;left: 0;top: 0; white-space: nowrap;overflow: hidden; color: #fde16d;} .empty-stars:before, .full-stars:before {content:&quot;\2605\2605\2605\2605\2605&quot;; font-size: 14pt;}.empty-stars:before {-webkit-text-stroke: 1px #848484;}.full-stars:before {-webkit-text-stroke: 1px orange;} @-moz-document url-prefix() {.full-stars {color: #ECBE24;}}&lt;/style&gt;');&quot;  - Unexpected &quot;: &quot;, expected one of: &quot;}&quot; &lt;-- 
thrown in <b>C:\htdocs\vendor\smarty\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php</b> on line <b>30</b><br />

原因是什么

if ($('h1').length) {
$('h1').after('<span>' + message[1] + '<div class="ratings"><div class="empty-stars"><div class="full-stars" style="width=(avgStars*20)%"></div></div></div></span>');
$('head').append('<style> .ratings {position: relative !important;vertical-align: middle!important;display: inline-block!important;color: #b1b1b1!important; overflow: hidden!important;}.full-stars {position: absolute;left: 0;top: 0; white-space: nowrap;overflow: hidden; color: #fde16d;} .empty-stars:before, .full-stars:before {content:"\2605\2605\2605\2605\2605"; font-size: 14pt;}.empty-stars:before {-webkit-text-stroke: 1px #848484;}.full-stars:before {-webkit-text-stroke: 1px orange;} @-moz-document url-prefix() {.full-stars {color: #ECBE24;}}</style>');
}

有什么想法吗?

最佳答案

您必须将 JS 代码包装在 {literal} 中标签,如果它在 Smarty 模板文件中。您的代码应该是:

{literal}
if ($('h1').length) {
$('h1').after('<span>' + message[1] + '<div class="ratings"><div class="empty-stars"><div class="full-stars" style="width=(avgStars*20)%"></div></div></div></span>');
$('head').append('<style> .ratings {position: relative !important;vertical-align: middle!important;display: inline-block!important;color: #b1b1b1!important; overflow: hidden!important;}.full-stars {position: absolute;left: 0;top: 0; white-space: nowrap;overflow: hidden; color: #fde16d;} .empty-stars:before, .full-stars:before {content:"\2605\2605\2605\2605\2605"; font-size: 14pt;}.empty-stars:before {-webkit-text-stroke: 1px #848484;}.full-stars:before {-webkit-text-stroke: 1px orange;} @-moz-document url-prefix() {.full-stars {color: #ECBE24;}}</style>');
}
{/literal}

它应该可以工作。如果没有,请将您的Smarty模板文件的完整代码放在您的问题中,我可能会帮助您。

关于javascript - 不存在的 Smarty 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50157068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com