mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 04:24:18 +02:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46e571fedd | |||
| 15e48b6af3 | |||
| d5adea5863 | |||
| 8041d0a4e8 | |||
| 94d9861d29 | |||
| 63ff7d81e0 | |||
| e6b6a0cbb2 | |||
| 0912124c33 | |||
| c0306d9942 | |||
| 3fff0813e8 | |||
| 3714d9ad8d | |||
| 1820e875dc | |||
| a112c7446c | |||
| aab7f3db71 | |||
| 08c90664f0 |
@@ -31,6 +31,7 @@ jobs:
|
||||
- "8.0"
|
||||
- "8.1"
|
||||
- "8.2"
|
||||
- "8.3"
|
||||
|
||||
compiler:
|
||||
- default
|
||||
@@ -45,6 +46,9 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.2"
|
||||
compiler: jit
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.3"
|
||||
compiler: jit
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
+10
-1
@@ -6,8 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [5.0.0-rc2] - 2023-11-11
|
||||
### Added
|
||||
- PHP8.3 support [#925](https://github.com/smarty-php/smarty/issues/925)
|
||||
- Backlink to GitHub in docs
|
||||
- Explain how to do escaping and set-up auto-escaping in docs [#865](https://github.com/smarty-php/smarty/issues/865)
|
||||
- Link to variable scope page in the documentation for the assign tag [#878](https://github.com/smarty-php/smarty/issues/878)
|
||||
|
||||
### Fixed
|
||||
- The {debug} tag was broken in v5 [#922](https://github.com/smarty-php/smarty/issues/922)
|
||||
- Documentation on `{if $x is even by $y}` syntax
|
||||
|
||||
## [5.0.0-rc2] - 2023-11-11
|
||||
|
||||
### Fixed
|
||||
- Registered output filters wouldn't run [#899](https://github.com/smarty-php/smarty/issues/899)
|
||||
|
||||
@@ -7,7 +7,7 @@ Smarty is a template engine for PHP, facilitating the separation of presentation
|
||||
Read the [documentation](https://smarty-php.github.io/smarty/) to find out how to use it.
|
||||
|
||||
## Requirements
|
||||
Smarty v5 can be run with PHP 7.2 to PHP 8.2.
|
||||
Smarty v5 can be run with PHP 7.2 to PHP 8.3.
|
||||
|
||||
## Installation
|
||||
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
- Fix incorrect compilation of expressions when escape_html=true [#930](https://github.com/smarty-php/smarty/pull/930)
|
||||
+5
-1
@@ -37,7 +37,11 @@ services:
|
||||
service: base
|
||||
build:
|
||||
dockerfile: ./utilities/testrunners/php82/Dockerfile
|
||||
|
||||
php83:
|
||||
extends:
|
||||
service: base
|
||||
build:
|
||||
dockerfile: ./utilities/testrunners/php83/Dockerfile
|
||||
volumes:
|
||||
smarty-code:
|
||||
|
||||
|
||||
+2
-1
@@ -89,4 +89,5 @@ Run this, and you will see:
|
||||
```
|
||||
|
||||
Note how the [escape modifier](../designers/language-modifiers/language-modifier-escape.md)
|
||||
translated the `&` character into the proper HTML syntax `&`.
|
||||
translated the `&` character into the proper HTML syntax `&`.
|
||||
Read more about auto-escaping in the [next section](./configuring.md).
|
||||
@@ -122,6 +122,24 @@ $smarty->setCacheDir('/data/caches');
|
||||
$cacheDir = $smarty->getCacheDir();
|
||||
```
|
||||
|
||||
## Enabling auto-escaping
|
||||
By default, Smarty does not escape anything you render in your templates. If you use
|
||||
Smarty to render a HTML-page, this means that you will have to make sure that you do
|
||||
not render any characters that have a special meaning in HTML, such as `&`, `<` and `>`,
|
||||
or apply the [escape modifier](../designers/language-modifiers/language-modifier-escape.md)
|
||||
to anything you want to render.
|
||||
|
||||
If you forget to do so, you may break your HTML page, or even create a vulnerability for
|
||||
attacks known as [XSS or Cross Site Scripting](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html).
|
||||
|
||||
Luckily, you can tell Smarty to automatically apply the escape modifier to any dynamic part of your template.
|
||||
It's like Smarty magically adds `|escape` to every variable you use on a web page.
|
||||
|
||||
Enable auto-escaping for HTML as follows:
|
||||
```php
|
||||
$smarty->setEscapeHtml(true);
|
||||
```
|
||||
|
||||
## Disabling compile check
|
||||
By default, Smarty tests to see if the
|
||||
current template has changed since the last time
|
||||
|
||||
@@ -10,4 +10,7 @@ template.
|
||||
{$foo:bar}
|
||||
```
|
||||
|
||||
NB. Support for using streams to call variables is deprecated since Smarty v5.1 and will be removed
|
||||
in a future version.
|
||||
|
||||
See also [`Template Resources`](../resources.md)
|
||||
|
||||
@@ -8,12 +8,12 @@ execution of a template**.
|
||||
|----------------|------------|-----------------------------------------------------------------------|
|
||||
| var | | The name of the variable being assigned |
|
||||
| value | | The value being assigned |
|
||||
| scope | (optional) | The scope of the assigned variable: \'parent\',\'root\' or \'global\' |
|
||||
| scope | (optional) | The scope of the assigned variable: 'parent','root' or 'global' |
|
||||
|
||||
## Attributes of the {$var=...} syntax
|
||||
| Attribute Name | Required | Description |
|
||||
|----------------|------------|-----------------------------------------------------------------------|
|
||||
| scope | (optional) | The scope of the assigned variable: \'parent\',\'root\' or \'global\' |
|
||||
| scope | (optional) | The scope of the assigned variable: 'parent','root' or 'global' |
|
||||
|
||||
## Option Flags
|
||||
| Name | Description |
|
||||
@@ -102,6 +102,8 @@ A global variable is seen by all templates.
|
||||
{$foo="bar" scope="global"}
|
||||
```
|
||||
|
||||
For more information on variable scope, please read the page on [variable scopes](../language-variables/language-variable-scopes.md).
|
||||
|
||||
To access `{assign}` variables from a php script use
|
||||
[`getTemplateVars()`](../../programmers/api-functions/api-get-template-vars.md).
|
||||
Here's the template that creates the variable `$foo`.
|
||||
|
||||
@@ -252,7 +252,7 @@ iteration.
|
||||
|
||||
```smarty
|
||||
{foreach $myNames as $name}
|
||||
{if $name@iteration is even by 3}
|
||||
{if $name@index is even by 3}
|
||||
<span style="color: #000">{$name}</span>
|
||||
{else}
|
||||
<span style="color: #eee">{$name}</span>
|
||||
|
||||
@@ -478,13 +478,13 @@ header block every five rows.
|
||||
</table>
|
||||
```
|
||||
|
||||
An example that uses the `iteration` property to alternate a text color every
|
||||
An example that uses the `index` property to alternate a text color every
|
||||
third row.
|
||||
|
||||
```smarty
|
||||
<table>
|
||||
{section name=co loop=$contacts}
|
||||
{if $smarty.section.co.iteration is even by 3}
|
||||
{if $smarty.section.co.index is even by 3}
|
||||
<span style="color: #ffffff">{$contacts[co].name}</span>
|
||||
{else}
|
||||
<span style="color: #dddddd">{$contacts[co].name}</span>
|
||||
|
||||
+18
-2
@@ -1,7 +1,7 @@
|
||||
# Getting started
|
||||
|
||||
## Requirements
|
||||
Smarty can be run with PHP 7.2 to PHP 8.2.
|
||||
Smarty can be run with PHP 7.2 to PHP 8.3.
|
||||
|
||||
## Installation
|
||||
Smarty can be installed with [Composer](https://getcomposer.org/).
|
||||
@@ -86,7 +86,7 @@ needs to be located in the [`$template_dir`](./programmers/api-variables/variabl
|
||||
|
||||
```smarty
|
||||
{* Smarty *}
|
||||
Hello {$name}, welcome to Smarty!
|
||||
<h1>Hello {$name|escape}, welcome to Smarty!</h1>
|
||||
```
|
||||
|
||||
> **Note**
|
||||
@@ -132,6 +132,20 @@ Now, run your PHP file. You should see *"Hello Ned, welcome to Smarty!"*
|
||||
|
||||
You have completed the basic setup for Smarty!
|
||||
|
||||
## Escaping
|
||||
You may have noticed that the example template above renders the `$name` variable using
|
||||
the [escape modifier](./designers/language-modifiers/language-modifier-escape.md). This
|
||||
modifier makes string 'safe' to use in the context of an HTML page.
|
||||
|
||||
If you are primarily using Smarty for HTML-pages, it is recommended to enable automatic
|
||||
escaping. This way, you don't have to add `|escape` to every variable you use on a web page.
|
||||
Smarty will handle it automatically for you!
|
||||
|
||||
Enable auto-escaping for HTML as follows:
|
||||
```php
|
||||
$smarty->setEscapeHtml(true);
|
||||
```
|
||||
|
||||
## Extended Setup
|
||||
|
||||
This is a continuation of the [basic installation](#installation), please read that first!
|
||||
@@ -156,6 +170,8 @@ class My_GuestBook extends Smarty {
|
||||
$this->setCompileDir('/web/www.example.com/guestbook/templates_c/');
|
||||
$this->setConfigDir('/web/www.example.com/guestbook/configs/');
|
||||
$this->setCacheDir('/web/www.example.com/guestbook/cache/');
|
||||
|
||||
$this->setEscapeHtml(true);
|
||||
|
||||
$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
|
||||
$this->assign('app_name', 'Guest Book');
|
||||
|
||||
@@ -26,6 +26,10 @@ and 480 for $height, the result is:
|
||||
- [Features](./features.md) - or "Why do I want Smarty?"
|
||||
|
||||
## Help
|
||||
- [Search or create an issue](https://github.com/smarty-php/smarty/issues)
|
||||
- [Upgrading from an older version](upgrading.md)
|
||||
- [Some random tips & tricks](./appendixes/tips.md)
|
||||
- [Troubleshooting](./appendixes/troubleshooting.md)
|
||||
|
||||
## Source code
|
||||
- [Smarty repository at GitHub](https://github.com/smarty-php/smarty)
|
||||
@@ -13,3 +13,4 @@ $COMPOSE_CMD run --rm php74 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php80 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php81 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php82 ./run-tests.sh $@
|
||||
$COMPOSE_CMD run --rm php83 ./run-tests.sh $@
|
||||
|
||||
@@ -84,7 +84,7 @@ class PrintExpressionCompiler extends Base {
|
||||
}
|
||||
|
||||
if ($compiler->getTemplate()->getSmarty()->escape_html) {
|
||||
$output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')";
|
||||
$output = "htmlspecialchars((string) ({$output}), ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+37
-46
@@ -6,16 +6,7 @@ namespace Smarty;
|
||||
* Smarty Internal Plugin Debug
|
||||
* Class to collect data for the Smarty Debugging Console
|
||||
*
|
||||
|
||||
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Debug Class
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
class Debug extends Data
|
||||
{
|
||||
@@ -24,14 +15,14 @@ class Debug extends Data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $template_data = array();
|
||||
public $template_data = [];
|
||||
|
||||
/**
|
||||
* List of uid's which shall be ignored
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $ignore_uid = array();
|
||||
public $ignore_uid = [];
|
||||
|
||||
/**
|
||||
* Index of display() and fetch() calls
|
||||
@@ -50,10 +41,10 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging template
|
||||
*
|
||||
* @param \Smarty\Template $template template
|
||||
* @param Template $template template
|
||||
* @param null $mode true: display false: fetch null: subtemplate
|
||||
*/
|
||||
public function start_template(\Smarty\Template $template, $mode = null)
|
||||
public function start_template(Template $template, $mode = null)
|
||||
{
|
||||
if (isset($mode) && !$template->_isSubTpl()) {
|
||||
$this->index++;
|
||||
@@ -67,9 +58,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of cache time
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function end_template(\Smarty\Template $template)
|
||||
public function end_template(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
|
||||
@@ -79,15 +70,15 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging of compile time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function start_compile(\Smarty\Template $template)
|
||||
public function start_compile(Template $template)
|
||||
{
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
if (!empty($template->getCompiler()->trace_uid)) {
|
||||
$key = $template->getCompiler()->trace_uid;
|
||||
if (!isset($this->template_data[ $this->index ][ $key ])) {
|
||||
$this->saveTemplateData($_is_stringy, $template, $key);
|
||||
$this->saveTemplateData($_is_stringy, $template, $key);
|
||||
}
|
||||
} else {
|
||||
if (isset($this->ignore_uid[ $template->getSource()->uid ])) {
|
||||
@@ -101,9 +92,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of compile time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function end_compile(\Smarty\Template $template)
|
||||
public function end_compile(Template $template)
|
||||
{
|
||||
if (!empty($template->getCompiler()->trace_uid)) {
|
||||
$key = $template->getCompiler()->trace_uid;
|
||||
@@ -120,9 +111,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging of render time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function start_render(\Smarty\Template $template)
|
||||
public function start_render(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
@@ -131,9 +122,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of compile time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function end_render(\Smarty\Template $template)
|
||||
public function end_render(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
|
||||
@@ -143,9 +134,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging of cache time
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function start_cache(\Smarty\Template $template)
|
||||
public function start_cache(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
@@ -154,9 +145,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of cache time
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function end_cache(\Smarty\Template $template)
|
||||
public function end_cache(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] +=
|
||||
@@ -166,9 +157,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Register template object
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function register_template(\Smarty\Template $template)
|
||||
public function register_template(Template $template)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -184,13 +175,13 @@ class Debug extends Data
|
||||
/**
|
||||
* Opens a window for the Smarty Debugging Console and display the data
|
||||
*
|
||||
* @param \Smarty\Template|\Smarty $obj object to debug
|
||||
* @param Template|Smarty $obj object to debug
|
||||
* @param bool $full
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Smarty\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function display_debug($obj, $full = false)
|
||||
public function display_debug($obj, bool $full = false)
|
||||
{
|
||||
if (!$full) {
|
||||
$this->offset++;
|
||||
@@ -200,18 +191,18 @@ class Debug extends Data
|
||||
$smarty = $obj->getSmarty();
|
||||
// create fresh instance of smarty for displaying the debug console
|
||||
// to avoid problems if the application did overload the Smarty class
|
||||
$debObj = new \Smarty\Smarty();
|
||||
$debObj = new Smarty();
|
||||
// copy the working dirs from application
|
||||
$debObj->setCompileDir($smarty->getCompileDir());
|
||||
$debObj->compile_check = \Smarty::COMPILECHECK_ON;
|
||||
$debObj->compile_check = Smarty::COMPILECHECK_ON;
|
||||
$debObj->security_policy = null;
|
||||
$debObj->debugging = false;
|
||||
$debObj->debugging_ctrl = 'NONE';
|
||||
$debObj->error_reporting = E_ALL & ~E_NOTICE;
|
||||
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . __DIR__ . '/../debug.tpl';
|
||||
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . __DIR__ . '/debug.tpl';
|
||||
$debObj->registered_resources = array();
|
||||
$debObj->escape_html = true;
|
||||
$debObj->caching = \Smarty::CACHING_OFF;
|
||||
$debObj->caching = Smarty::CACHING_OFF;
|
||||
// prepare information of assigned variables
|
||||
$ptr = $this->get_debug_vars($obj);
|
||||
$_assigned_vars = $ptr->tpl_vars;
|
||||
@@ -223,7 +214,7 @@ class Debug extends Data
|
||||
$displayMode = $debugging === 2 || !$full;
|
||||
$offset = $this->offset * 50;
|
||||
$_template = $debObj->doCreateTemplate($debObj->debug_tpl);
|
||||
if ($obj instanceof \Smarty\Template) {
|
||||
if ($obj instanceof Template) {
|
||||
$_template->assign('template_name', $templateName);
|
||||
} elseif ($obj instanceof Smarty || $full) {
|
||||
$_template->assign('template_data', $this->template_data[$this->index]);
|
||||
@@ -298,11 +289,11 @@ class Debug extends Data
|
||||
/**
|
||||
* Return key into $template_data for template
|
||||
*
|
||||
* @param \Smarty\Template $template template object
|
||||
* @param Template $template template object
|
||||
*
|
||||
* @return string key into $template_data
|
||||
*/
|
||||
private function get_key(\Smarty\Template $template)
|
||||
private function get_key(Template $template)
|
||||
{
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
|
||||
@@ -319,9 +310,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Ignore template
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function ignore(\Smarty\Template $template)
|
||||
public function ignore(Template $template)
|
||||
{
|
||||
$this->ignore_uid[$template->getSource()->uid] = true;
|
||||
}
|
||||
@@ -329,9 +320,9 @@ class Debug extends Data
|
||||
/**
|
||||
* handle 'URL' debugging mode
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param Smarty $smarty
|
||||
*/
|
||||
public function debugUrl(\Smarty $smarty)
|
||||
public function debugUrl(Smarty $smarty)
|
||||
{
|
||||
if (isset($_SERVER[ 'QUERY_STRING' ])) {
|
||||
$_query_string = $_SERVER[ 'QUERY_STRING' ];
|
||||
@@ -360,12 +351,12 @@ class Debug extends Data
|
||||
|
||||
/**
|
||||
* @param array $_is_stringy
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
* @param string $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function saveTemplateData(array $_is_stringy, \Smarty\Template $template, string $key): void {
|
||||
private function saveTemplateData(array $_is_stringy, Template $template, string $key): void {
|
||||
if (isset($_is_stringy[$template->getSource()->type])) {
|
||||
$this->template_data[$this->index][$key]['name'] =
|
||||
'\'' . substr($template->getSource()->name, 0, 25) . '...\'';
|
||||
|
||||
@@ -77,7 +77,7 @@ class ErrorHandler
|
||||
}
|
||||
|
||||
if ($this->allowUndefinedArrayKeys && preg_match(
|
||||
'/^(Undefined index|Undefined array key|Trying to access array offset on value of type)/',
|
||||
'/^(Undefined index|Undefined array key|Trying to access array offset on)/',
|
||||
$errstr
|
||||
)) {
|
||||
return; // suppresses this error
|
||||
|
||||
+3
-2
@@ -251,9 +251,10 @@ class Smarty extends \Smarty\TemplateBase {
|
||||
|
||||
/**
|
||||
* debug mode
|
||||
* Setting this to true enables the debug-console.
|
||||
* Setting this to true enables the debug-console. Setting it to 2 enables individual Debug Console window by
|
||||
* template name.
|
||||
*
|
||||
* @var boolean
|
||||
* @var boolean|int
|
||||
*/
|
||||
public $debugging = false;
|
||||
|
||||
|
||||
@@ -555,6 +555,9 @@ class Template extends TemplateBase {
|
||||
*/
|
||||
public function getStreamVariable($variable)
|
||||
{
|
||||
|
||||
trigger_error("Using stream variables (\`\{\$foo:bar\}\`)is deprecated.", E_USER_DEPRECATED);
|
||||
|
||||
$_result = '';
|
||||
$fp = fopen($variable, 'r+');
|
||||
if ($fp) {
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
{capture name='_smarty_debug' assign=debug_output}
|
||||
{capture name='_smarty_debug' assign='debug_output'}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -108,7 +108,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty {Smarty::SMARTY_VERSION} Debug Console
|
||||
<h1>Smarty {\Smarty\Smarty::SMARTY_VERSION} Debug Console
|
||||
- {if isset($template_name)}{$template_name|debug_print_var nofilter} {/if}{if !empty($template_data)}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
{if !empty($template_data)}
|
||||
@@ -166,7 +166,7 @@
|
||||
</body>
|
||||
</html>
|
||||
{/capture}
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
_smarty_console = window.open("", "console{$targetWindow}", "width=1024,height=600,left={$offset},top={$offset},resizable,scrollbars=yes");
|
||||
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
|
||||
_smarty_console.document.close();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace UnitTests\TemplateSource\TagTests\Debug;
|
||||
use PHPUnit_Smarty;
|
||||
use Smarty\Smarty;
|
||||
|
||||
/**
|
||||
* Smarty PHPunit tests of {debug} tag
|
||||
*/
|
||||
class PluginModifierStripTagsTest extends PHPUnit_Smarty {
|
||||
|
||||
public function setUp(): void {
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
public function testDefault() {
|
||||
$tpl = $this->smarty->createTemplate('eval:{debug}');
|
||||
$output = $this->smarty->fetch($tpl);
|
||||
$this->assertStringContainsString("<script", $output);
|
||||
$this->assertStringContainsString("</script>", $output);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,7 +103,37 @@ class CompileIfTest extends PHPUnit_Smarty
|
||||
array('{if 6 is not even}yes{else}no{/if}', 'no', 'IsNotEven', $i ++),
|
||||
array('{if 3 is odd}yes{else}no{/if}', 'yes', 'IsOdd', $i ++),
|
||||
array('{if 3 is not odd}yes{else}no{/if}', 'no', 'IsNotOdd', $i ++),
|
||||
array('{$foo=3}{if 3 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar', $i ++),
|
||||
|
||||
array('{if 0 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest0', $i ++),
|
||||
array('{if 1 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest1', $i ++),
|
||||
array('{if 2 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest2', $i ++),
|
||||
array('{if 3 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByTest3', $i ++),
|
||||
array('{if 4 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByTest4', $i ++),
|
||||
array('{if 5 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByTest5', $i ++),
|
||||
array('{if 6 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest6', $i ++),
|
||||
array('{if 7 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByTest7', $i ++),
|
||||
|
||||
array('{if 0 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest0', $i ++),
|
||||
array('{if 1 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest1', $i ++),
|
||||
array('{if 2 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest2', $i ++),
|
||||
array('{if 3 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByTest3', $i ++),
|
||||
array('{if 4 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByTest4', $i ++),
|
||||
array('{if 5 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByTest5', $i ++),
|
||||
array('{if 6 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest6', $i ++),
|
||||
array('{if 7 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByTest7', $i ++),
|
||||
|
||||
array('{if 2 is even by 3}yes{else}no{/if}', 'yes', 'IsEvenByVal1', $i ++),
|
||||
array('{if 3 is even by 2}yes{else}no{/if}', 'no', 'IsEvenByVal2', $i ++),
|
||||
array('{if 4 is even by 3}yes{else}no{/if}', 'no', 'IsEvenByVal3', $i ++),
|
||||
array('{$foo=3}{if 2 is even by $foo}yes{else}no{/if}', 'yes', 'IsEvenByVar1', $i ++),
|
||||
array('{$foo=2}{if 3 is even by $foo}yes{else}no{/if}', 'no', 'IsEvenByVar2', $i ++),
|
||||
array('{$foo=3}{if 4 is even by $foo}yes{else}no{/if}', 'no', 'IsEvenByVar3', $i ++),
|
||||
array('{if 2 is odd by 3}yes{else}no{/if}', 'no', 'IsOddByVal1', $i ++),
|
||||
array('{if 3 is odd by 2}yes{else}no{/if}', 'yes', 'IsOddByVal2', $i ++),
|
||||
array('{if 4 is odd by 3}yes{else}no{/if}', 'yes', 'IsOddByVal3', $i ++),
|
||||
array('{$foo=3}{if 2 is odd by $foo}yes{else}no{/if}', 'no', 'IsOddByVar1', $i ++),
|
||||
array('{$foo=2}{if 3 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar2', $i ++),
|
||||
array('{$foo=3}{if 4 is odd by $foo}yes{else}no{/if}', 'yes', 'IsOddByVar3', $i ++),
|
||||
array('{$foo=3}{$bar=6}{if $bar is not odd by $foo}yes{else}no{/if}', 'yes', 'IsNotOddByVar', $i ++),
|
||||
array('{$foo=3}{$bar=3}{if 3+$bar is not odd by $foo}yes{else}no{/if}', 'yes', 'ExprIsNotOddByVar', $i ++),
|
||||
array('{$foo=2}{$bar=6}{if (3+$bar) is not odd by ($foo+1)}yes{else}no{/if}', 'no', 'ExprIsNotOddByExpr', $i ++),
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
FROM php:8.3-cli
|
||||
|
||||
## Basic utilities
|
||||
RUN apt-get update -yqq && apt-get install -y curl apt-utils git zip unzip
|
||||
|
||||
## Composer
|
||||
COPY ./utilities/testrunners/shared/install-composer.sh /root/install-composer.sh
|
||||
WORKDIR /root
|
||||
RUN sh ./install-composer.sh
|
||||
RUN mv ./composer.phar /usr/local/bin/composer
|
||||
Reference in New Issue
Block a user