Содержание
- Syntax Error in template Есть решение
- Ошибка #0
- Syntax Error in template
- on line 1 «» — Unexpected «:», expected one of: «>» , » » , ATTR
- 9 ответов
- Smarty Compiler: Syntax error in template
- Recommended Posts
- <$product->name|escape:’html’:’UTF-8’>
- Как добавить код счётчика яндекс метрики в шаблон Smarty
- _.template syntax errors too hard to debug #666
- Comments
- Template literals (Template strings)
- Syntax
- Parameters
- Description
- Multi-line strings
- String interpolation
- Nesting templates
- Tagged templates
- Raw strings
- Tagged templates and escape sequences
Syntax Error in template Есть решение
Помогите устранить ошибку
Ошибка #0
Syntax Error in template
on line 1 «» — Unexpected «:», expected one of: «>» , » » , ATTR
9 ответов
после открывающей фигурной скобки пробел ставьте в стилях
дело в том что они не сжаты на сервере лежат, обычные стили с пробелами и читабельны
у вас стили внутри шаблона заданы. Если после фигурной скобки нет пробела, smarty считает это своим выражением.
Вы имеете ввиду внутри html гдето так написанно?
когда включил Режим отладки (debug mode) вот такая ошибка
exception ‘SmartyCompilerException’ with message ‘Syntax Error in template «a4e97eca6e34e6411aa7f11454ce0eede378d953» on line 1 «» — Unexpected «:», expected one of: «>» , » » , ATTR’ in /var/www/seeds/data/www/semochka.com/wa-system/vendors/smarty3/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /var/www/seeds/data/www/semochka.com/wa-system/vendors/smarty3/sysplugins/smarty_internal_templateparser.php(3144): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 /var/www/seeds/data/www/semochka.com/wa-system/vendors/smarty3/sysplugins/smarty_internal_templateparser.php(3209): Smarty_Internal_Templateparser->yy_syntax_error(2, ‘:’) #2 /var/www/seeds/data/www/semochka.com/wa-system/vendors/smarty3/sysplugins/smarty_internal_smartytemplatecompiler.php(105): Smarty_Internal_Templateparser->doParse(2, ‘:’) #3 /var/www/seeds/data/www/semochka.com/wa-system/vendors/smarty3/sysplugins/smarty_internal_templatecompilerbase.php(206): Smarty_Internal_SmartyTemplateCompiler->doCompile(‘
В какой момент появляется ошибка?
в конце оформления заказа после выбора способа оплаты и нажатии кнопки оформить заказ. При этом он оформляется в магазине но покупателю неприходит никакого уведомления
Проверяйте шаблоны уведомлений на email, где-то в нем есть лишняя скобка.
Спасиба! действительно да в одном из шаблонов css поправил просто сделал его читабельней и все поехало)
Источник
Smarty Compiler: Syntax error in template
By nex_toto ,
September 19, 2017 in General topics
Recommended Posts
= 0 || $quantity_discount.reduction_type == ‘amount’> <$realDiscountPrice=$quantity_discount.base_price|floatval-$quantity_discount.real_value|floatval> name|escape:’html’:’UTF-8’>
<$product->name|escape:’html’:’UTF-8’>
reference) || !$product->reference> style=»display: none;»> reference) && $product->reference> content=»<$product->reference>»><$product->reference|escape:’html’:’UTF-8’>
description_short || $packItems|@count > 0>
quantity <$product->quantity|intval> quantity > 1> style=»display: none;» > quantity == 1> style=»display: none;» >
quantity > $last_qties || $product->quantity available_for_order || $PS_CATALOG_MODE> style=»display: none» >
quantity > 0) || !$product->available_for_order || $PS_CATALOG_MODE || !isset($product->available_date) || $product->available_date available_date)>available_date full=false>
Источник
Как добавить код счётчика яндекс метрики в шаблон Smarty
Достался на продвижение и обслуживание корпоративный сайт, работающий под управлением HOST-CMS одной из самых первых версий. Возникла необходимость установить на сайт счётчик яндекс-метрики. Но при его установке возникла ошибка: «syntax error: unrecognized tag ‘var’«. Почему возникает эта ошибка и как её побороть, расскажу в этом посте. Как известно, ранние версии движка HOST-CMS работают на шаблонах Smarty. Одной из особенностей этого шаблонизатора является его особенная обработка фигурных скобок, которые включены непосредственно в шаблон. Компилятор Smarty обрабатывает эти скобки «как свои», в результате чего возникают ошибки вида
- Fatal error: Uncaught exception ‘SmartyCompilerException’ with message ‘Syntax Error in template «…/
- string(92) «Smarty error: [in tpl_head:12 line 36]: syntax error: unrecognized tag ‘var’ (Smarty_Compiler.class.php, line 261)»
а также нарушается целостность html-вёрстки сайта. В исходном коде же яндекс-метрики как раз содержатся фигурные скобки и «просто так» вставить код счётчика не получится.
Что делать? Нужно всего лишь обернуть код счётчика в специальные теги
где вместо многоточия — ваш код.
Также для эранирования фигурных скобок в скриптах можно использовать и конструкцию
Важный момент: смотрите внимательно, какой именно шаблон отвечает за вывод кода счётчика Метрики. Для неподготовленного пользователя это не всегда очевидно.
Источник
_.template syntax errors too hard to debug #666
If you have a syntax error in your generated template, you just get an exception from var render = new Function(settings.variable || ‘obj’, ‘_’, source); – not very helpful, and you can’t view the source of the template.
I’m not quite sure what to do, though try/catch around that might help. The exception itself will always be kind of bad. So maybe:
And that would have to be documented, I guess, otherwise you’d never notice that. And I’m not sure if all errors can have attributes added to them. But. something would be helpful.
The text was updated successfully, but these errors were encountered:
Hi @ianb! You’re right, syntax errors from new Function(. ) are hard to debug since you don’t get a line number. However, two things have been done recently to help with this (in the latest version of underscore).
- Source Lines — Template source lines are now separated instead of munged into one. At the very least, this makes it much easier to debug the error from the console.
- Precompilation — Since it’s now possible to precompile templates via _.template(. ).source , you can precompile your templates server-side and send them to the browser as plain javascript. This means you’ll get line numbers with the syntax error. Even if you can’t precompile them server-side you can still debug the syntax error with a quick node script to compile the template.
Hope these help!
Note that syntax errors are a little different than runtime errors. I should have given an example: _.template(‘ ‘)
There’s no successful template object created because just constructing the Function object fails.
lodash tried to address this in this commit: lodash/lodash@10886be
Ah. Yes, of course, though the first point still stands. 🙂
Why is it helpful to defer throwing the error? It seems to me this would lead to silent template compilation failures.
lodash’s change is not the one I’d have thought of, though in the particular case I encountered it would have been helpful. In cases where you aren’t aggressively precompiling templates I think lodash’s approach is sensible – deferring the error for a couple lines of code doesn’t make it harder to debug. Annotating or rewriting the exception object is more what I’d expect.
Also as it currently stands the first point would be helpful if I could get my hands on the syntactically invalid generated code, but right now I can’t.
Why is it helpful to defer throwing the error?
This way the template and its source are debuggable. Normally, for non-syntax error related failures compiled templates that error when passed a data object, either through _.template(string, data) or deferred via _.template(string) , have sourceURLs associated with them so devs can simply look them up in their console to see the compiled source.
It seems to me this would lead to silent template compilation failures.
Because errors are deferred until execution rather than creation it allows it to be debugged in the same way you suggested.
This way the template and its source are debuggable.
You mean that you can still do console.log(_.template(‘. ‘).source) when the template has a syntax error?
You mean that you can still do console.log(_.template(‘. ‘).source) when the template has a syntax error?
I see how that’s handy, but it poses a problem when precompiling templates. The code below would spit out code with a syntax error without warning, which I think is undesirable.
I see how that’s handy, but it poses a problem when precompiling templates. The code below would spit out code with a syntax error without warning, which I think is undesirable.
They would be debugging it because it threw an error in the first place. The warning bells will have already been sounded.
I meant precompiling server-side before delivering to the browser, where the template would not be executed.
I meant precompiling server-side before delivering to the browser, where the template would not be executed.
If they precompile and use the .source to inline it for delivery then it will error on client. Then they will go debugging the template they just inlined on the server-side and will be able to.
I make heavy use of compiled and inlined templates during the runtime and build process of Lo-Dash. If I or any other dev runs into issues or annoyances with the safeguard I’ll simply tweak it. I’m going to stick it out for now.
Источник
Template literals (Template strings)
Template literals are literals delimited with backtick ( ` ) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.
Template literals are sometimes informally called template strings, because they are used most commonly for string interpolation (to create strings by doing substitution of placeholders). However, a tagged template literal may not result in a string; it can be used with a custom tag function to perform whatever operations you want on the different parts of the template literal.
Syntax
Parameters
The string text that will become part of the template literal. Almost all characters are allowed literally, including line breaks and other whitespace characters. However, invalid escape sequences will cause a syntax error, unless a tag function is used.
An expression to be inserted in the current position, whose value is converted to a string or passed to tagFunction .
If specified, it will be called with the template strings array and substitution expressions, and the return value becomes the value of the template literal. See tagged templates.
Description
Template literals are enclosed by backtick ( ` ) characters instead of double or single quotes.
Along with having normal strings, template literals can also contain other parts called placeholders, which are embedded expressions delimited by a dollar sign and curly braces: $ . The strings and placeholders get passed to a function — either a default function, or a function you supply. The default function (when you don’t supply your own) just performs string interpolation to do substitution of the placeholders and then concatenate the parts into a single string.
To supply a function of your own, precede the template literal with a function name; the result is called a tagged template. In that case, the template literal is passed to your tag function, where you can then perform whatever operations you want on the different parts of the template literal.
To escape a backtick in a template literal, put a backslash ( ) before the backtick.
Dollar signs can be escaped as well to prevent interpolation.
Multi-line strings
Any newline characters inserted in the source are part of the template literal.
Using normal strings, you would have to use the following syntax in order to get multi-line strings:
Using template literals, you can do the same with this:
String interpolation
Without template literals, when you want to combine output from expressions with strings, you’d concatenate them using the addition operator + :
That can be hard to read – especially when you have multiple expressions.
With template literals, you can avoid the concatenation operator — and improve the readability of your code — by using placeholders of the form $ to perform substitutions for embedded expressions:
Note that there’s a mild difference between the two syntaxes. Template literals coerce their expressions directly to strings, while addition coerces its operands to primitives first. For more information, see the reference page for the + operator.
Nesting templates
In certain cases, nesting a template is the easiest (and perhaps more readable) way to have configurable strings. Within a backtick-delimited template, it is simple to allow inner backticks by using them inside an $ placeholder within the template.
For example, without template literals, if you wanted to return a certain value based on a particular condition, you could do something like the following:
With a template literal but without nesting, you could do this:
With nesting of template literals, you can do this:
Tagged templates
A more advanced form of template literals are tagged templates.
Tags allow you to parse template literals with a function. The first argument of a tag function contains an array of string values. The remaining arguments are related to the expressions.
The tag function can then perform whatever operations on these arguments you wish, and return the manipulated string. (Alternatively, it can return something completely different, as described in one of the following examples.)
The name of the function used for the tag can be whatever you want.
The tag does not have to be a plain identifier. You can use any expression with precedence greater than 16, which includes property access, function call, new expression, or even another tagged template literal.
While technically permitted by the syntax, untagged template literals are strings and will throw a TypeError when chained.
The only exception is optional chaining, which will throw a syntax error.
Note that these two expressions are still parsable. This means they would not be subject to automatic semicolon insertion, which will only insert semicolons to fix code that’s otherwise unparsable.
Tag functions don’t even need to return a string!
The first argument received by the tag function is an array of strings. For any template literal, its length is equal to the number of substitutions (occurrences of $ <…>) plus one, and is therefore always non-empty.
For any particular tagged template literal expression, the tag function will always be called with the exact same literal array, no matter how many times the literal is evaluated.
This allows the tag to cache the result based on the identity of its first argument. To further ensure the array value’s stability, the first argument and its raw property are both frozen, so you can’t mutate them in any way.
Raw strings
The special raw property, available on the first argument to the tag function, allows you to access the raw strings as they were entered, without processing escape sequences.
In addition, the String.raw() method exists to create raw strings just like the default template function and string concatenation would create.
String.raw functions like an «identity» tag if the literal doesn’t contain any escape sequences. In case you want an actual identity tag that always works as if the literal is untagged, you can make a custom function that passes the «cooked» (i.e. escape sequences are processed) literal array to String.raw , pretending they are raw strings.
This is useful for many tools which give special treatment to literals tagged by a particular name.
Tagged templates and escape sequences
In normal template literals, the escape sequences in string literals are all allowed. Any other non-well-formed escape sequence is a syntax error. This includes:
- followed by any decimal digit other than 0 , or followed by a decimal digit; for example 9 and 7 (which is a deprecated syntax)
- x followed by fewer than two hex digits (including none); for example xz
- u not followed by < and followed by fewer than four hex digits (including none); for example uz
- u<> enclosing an invalid Unicode code point — it contains a non-hex digit, or its value is greater than 10FFFF ; for example u <110000>and u
Note: followed by other characters, while they may be useless since nothing is escaped, are not syntax errors.
However, this is problematic for tagged templates, which, in addition to the «cooked» literal, also have access to the raw literals (escape sequences are preserved as-is).
Tagged templates should allow the embedding of languages (for example DSLs, or LaTeX), where other escapes sequences are common. Therefore, the syntax restriction of well-formed escape sequences is removed from tagged templates.
However, illegal escape sequences must still be represented in the «cooked» representation. They will show up as undefined element in the «cooked» array:
Note that the escape-sequence restriction is only dropped from tagged templates, but not from untagged template literals:
Источник
Adblock
detector
id`-`$image.id_image`»>
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
ildar-aim opened this issue
Jul 26, 2021
· 10 comments
Comments
https://github.com/php/php-src/blob/php-8.1.0/UPGRADING
https://www.php.net/index.php#id2021-07-22-1
For example, this patch causes a fatal error
aim-server[~/www/smarty/demo]$ gitdiff .
diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl
index 1fbb6d37..1e125e15 100644
--- a/demo/templates/index.tpl
+++ b/demo/templates/index.tpl
@@ -1,6 +1,6 @@
{config_load file="test.conf" section="setup"}
{include file="header.tpl" title=foo}
-
+{php}{/php}
<PRE>
{* bold and title are read from the config file *}
Fatal error: Type of SmartyCompilerException::$line must be int (as in class Exception) in public_html/smarty/libs/sysplugins/smartycompilerexception.php on line 8
The expected error is
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:public_html/smarty/demo/templates/index.tpl" on line 3 "{php}{/php}" {php}{/php} tags not allowed. Use SmartyBC to enable them <-- thrown in public_html/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 3
what’s really nasty is that fixing the class to work with 8.1 makes it break for < 8.1.
the only fix I see is to either conditionally define the class depending on PHP version or alternatively renaming the property and using the changed name instead.
Which one would you prefer? I can do a PR for both.
I have created a copy of Smarty.class.php —
Smarty.PHP81.class.php
and the code is
if (PHP_VERSION_ID >= 80100) { // php 8.1.0
require_once(dirname(__FILE__) . '/Smarty.PHP81.class.php');
} else {
require_once(dirname(__FILE__) . '/Smarty.class.php');
}
if the problem being $line
being re-declared as public
from inherited Exception
class, can it be declared as private if used only in that class?
Smarty WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
www.smarty.net •
phpinsider.com •
Forum Index •
FAQ • Search
• Memberlist •
Profile
• Log in to check your private messages
• Register
• Log in
Fatal error: Uncaught exception ‘SmartyCompilerException’
Smarty Forum Index -> Installation and Setup |
View previous topic :: View next topic | |||||||
Author | Message | ||||||
---|---|---|---|---|---|---|---|
Tsukkie Smarty Rookie Joined: 31 Jul 2013 |
|
||||||
Back to top |
|
||||||
mohrt Administrator Joined: 16 Apr 2003 |
|
||||||
Back to top |
|
||||||
Tsukkie Smarty Rookie Joined: 31 Jul 2013 |
|
||||||
Back to top |
|
||||||
U.Tews Administrator Joined: 22 Nov 2006 |
|
||||||
Back to top |
|
||||||
Tsukkie Smarty Rookie Joined: 31 Jul 2013 |
|
||||||
Back to top |
|
||||||
mohrt Administrator Joined: 16 Apr 2003 |
|
||||||
Back to top |
|
||||||
mohrt Administrator Joined: 16 Apr 2003 |
|
||||||
Back to top |
|
||||||
Tsukkie Smarty Rookie Joined: 31 Jul 2013 |
|
||||||
Back to top |
|
||||||
Tsukkie Smarty Rookie Joined: 31 Jul 2013 |
|
||||||
Back to top |
|
||||||
mohrt Administrator Joined: 16 Apr 2003 |
|
||||||
Back to top |
|
||||||
Tsukkie Smarty Rookie Joined: 31 Jul 2013 |
|
||||||
Back to top |
|
||||||
U.Tews Administrator Joined: 22 Nov 2006 |
|
||||||
Back to top |
|
||||||
|
Smarty Forum Index -> Installation and Setup |
All times are GMT |
|
Page 1 of 1 |
Jump to: You cannot post new topics in this forum |
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP
sexy0123 0 / 0 / 0 Регистрация: 15.06.2010 Сообщений: 16 |
||||
1 |
||||
24.08.2012, 15:55. Показов 5506. Ответов 3 Метки нет (Все метки)
Доброго времени суток.
а вот ошибка(SIMPLACMS): Fatal error: Uncaught exception ‘SmartyCompilerException’ with message ‘Syntax Error in template «X:homemagazin4.aawww//design/default_1/htmlindex.tpl» on line 293 «VK.Widgets.Group("vk_groups", {mode: 0, width: "200", height: "290"}, 20003922);» — Unexpected «: «, expected one of: «}» , » «‘ in X:homemagazin4.aawwwSmartylibssyspluginssma rty_internal_templatecompilerbase.php:431 Stack trace: #0 X:homemagazin4.aawwwSmartylibssyspluginssma rty_internal_templateparser.php(2855): Smarty_Internal_TemplateCompilerBase->trigger_template_error() #1 X:homemagazin4.aawwwSmartylibssyspluginssma rty_internal_templateparser.php(2920): Smarty_Internal_Templateparser->yy_syntax_error(2, ‘: ‘) #2 X:homemagazin4.aawwwSmartylibssyspluginssma rty_internal_smartytemplatecompiler.php(51): Smarty_Internal_Templateparser->doParse(2, ‘: ‘) #3 X:homemagazin4.aawwwSmartylibssyspluginssma rty_internal_templatecompilerbase.php(82): Smarty_Internal_SmartyTemplateCompiler->doCompile(‘< in X:homemagazin4.aawwwSmartylibssyspluginssma rty_internal_templatecompilerbase.php on line 431
__________________
0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
24.08.2012, 15:55 |
Ответы с готовыми решениями:
сайт пишет вот такую ошибку PHP Parse error:…
синтаксический ошибка как… В чем ошибка (Parse error: syntax error, unexpected ‘$i’ (T_VARIABLE), expecting ‘;’) ? Ошибка Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRIN 3 |
600 / 568 / 104 Регистрация: 07.11.2010 Сообщений: 2,004 |
|
25.08.2012, 09:41 |
2 |
докуметацию то прочтите, как виджет подключать. В последнем числе соодержится номер сообщества
0 |
13207 / 6595 / 1041 Регистрация: 10.01.2008 Сообщений: 15,069 |
|
25.08.2012, 09:56 |
3 |
Код VK.Widgets.Group("vk_groups", {mode: Smarty думает, что {mode — это начало её тега. Попробуйте для начала добавить пробелы вокруг фигурных скобок: Код VK.Widgets.Group("vk_groups", { mode: 0, width: "200", height: "290" }, 20003922);
0 |
0 / 0 / 0 Регистрация: 28.04.2015 Сообщений: 1 |
|
28.04.2015, 15:21 |
4 |
Спасибо)
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
28.04.2015, 15:21 |
Помогаю со студенческими работами здесь Ошибка — Parse error: syntax error, unexpected ‘echo’ (T_ECHO) Ошибка — Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ Ошибка — Parse error: syntax error, unexpected ‘case’ (T_CASE) В чем ошибка Parse error: syntax error, unexpected T_STRING in Ошибка Parse error: syntax error, unexpected ‘}’, expecting T_WHILE Ошибка- Parse error: syntax error, unexpected ‘$title_logo’ (T_VARIABLE) Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 4 |