Skip to content

Commit

Permalink
- improvement show resource type and start of template source instead…
Browse files Browse the repository at this point in the history
… of uid on eval: and string: resource (forum topic 25630)
  • Loading branch information
uwetews committed Aug 1, 2015
1 parent 3d2a15b commit 05a8fa2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion change_log.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
 ===== 3.1.28-dev===== (xx.xx.2015)
01.08.2015
- update DateTime object can be instance of DateTimeImmutable since PHP5.5 https://github.com/smarty-php/smarty/pull/75

- improvement show resource type and start of template source instead of uid on eval: and string: resource (forum topic 25630)

31.07.2015
- optimize {foreach} and {section} compiler

Expand Down
2 changes: 1 addition & 1 deletion libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.28-dev/35';
const SMARTY_VERSION = '3.1.28-dev/36';

/**
* define variable scopes
Expand Down
10 changes: 9 additions & 1 deletion libs/sysplugins/smarty_internal_templatecompilerbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,10 +1079,18 @@ public function trigger_template_error($args = null, $line = null)
if (!isset($line)) {
$line = $this->lex->line;
}
if (in_array($this->template->source->type, array('eval', 'string'))) {
$templateName = $this->template->source->type . ':' .
trim(preg_replace('![\t\r\n]+!', ' ', strlen($this->lex->data) > 40 ? substr($this->lex->data, 0, 40) .
'...' : $this->lex->data));
} else {
$templateName = $this->template->source->type . ':' . $this->template->source->filepath;
}

// $line += $this->trace_line_offset;
$match = preg_split("/\n/", $this->lex->data);
$error_text = 'Syntax error in template "' .
(empty($this->trace_filepath) ? $this->template->source->filepath : $this->trace_filepath) . '" on line ' .
(empty($this->trace_filepath) ? $templateName : $this->trace_filepath) . '" on line ' .
($line + $this->trace_line_offset) . ' "' . trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) .
'" ';
if (isset($args)) {
Expand Down

0 comments on commit 05a8fa2

Please sign in to comment.