我得到的错误基本上不在这里,或者我是超级盲人,因为我已经花了最后30分钟。
<b>Fatal error</b>: Uncaught --> Smarty Compiler: Syntax error in template "file:C:\htdocs\smarty\templates\shopify_apps\bundle\js_modules\product_reviews.tpl" on line 30 "$('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>');" - Unexpected ": ", expected one of: "}" <--
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>');
}
任何想法?
答案 0 :(得分:2)
如果您的JS代码位于Smarty模板文件中,则必须将其包装在{literal}
标记中。您的代码应为:
{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模板文件的完整代码,我可能会帮助您。