疑似不存在的Smarty Bug?排查30分钟未发现的模板语法错误
Hey there, let's work through that frustrating Smarty syntax error you're stuck on. That fatal error on line 30 of product_reviews.tpl is almost definitely caused by how you're embedding inline CSS inside a JavaScript string within your Smarty template.
What's Going Wrong?
Smarty’s compiler tries to parse certain characters (like curly braces {}) as template syntax—even when they’re part of CSS or JavaScript code. When you throw !important declarations into the mix inside a quoted string, it confuses the compiler, leading to that truncated error message you’re seeing (it cuts off at !im... because the compiler got stuck mid-parsing).
Quick Fixes to Try
Use Smarty’s
literalTags (Cleanest Solution)
Wrap your entire JavaScript block that’s adding the style in{literal}{/literal}. This tells Smarty to treat everything inside as plain text, so it won’t try to interpret your CSS curly braces or!importantas template code. Here’s how it should look:{literal} $('head').append('<style> .ratings {position: relative !important;vertical-align: middle!important;display: inline-block!important;color: #b1b1b1!important;} </style>'); {/literal}Escape Curly Braces (If You Need Template Variables)
If you have Smarty variables inside that JavaScript/CSS block (so you can’t useliteral), escape each curly brace with a backslash:$('head').append('<style> .ratings \{position: relative !important;vertical-align: middle!important;display: inline-block!important;color: #b1b1b1!important;\} </style>');Note: This is more tedious, so only use it if you absolutely need to keep template variables in that block.
Double-Check for Truncated Code
Make sure your!importantdeclarations are fully written (no typos like!iminstead of!important)—the error message suggests the line might be cut off, which could also trigger a syntax issue.
内容的提问来源于stack exchange,提问作者Cristi Duma

