Compare commits

..

153 Commits

Author SHA1 Message Date
Simon Wisselink 0750fd7f1e Some more missed commits 2023-08-08 00:00:20 +02:00
Simon Wisselink 3750c644a5 Missed part of commit a3cbdc46 in the merge 2023-08-07 23:49:24 +02:00
Simon Wisselink 515c14b24f Missed part of commit e7516556 in the merge. 2023-08-07 23:44:08 +02:00
Simon Wisselink 077df8a771 remove docs from 'all' to prevent CI build from failing 2023-08-07 23:28:21 +02:00
Simon Wisselink 7a6cbca7e4 Merge branch 'master' into smarty5 2023-08-07 23:25:59 +02:00
Simon Wisselink dc46052aa7 fix template invalidation when migrating to 5.0 2023-08-07 16:22:54 +02:00
Simon Wisselink 92736c1cba updated todos 2023-08-07 16:00:16 +02:00
Simon Wisselink 90bb78f32d Added Smarty::setExtensions(), fixed unit test for the null coalescing operator. Updated docs about registering a custom extension. 2023-08-07 15:59:13 +02:00
Simon Wisselink d8b4496b7e finished docs on security and extending smarty 2023-08-07 01:44:57 +02:00
Simon Wisselink 8492bf5c61 Docs on caching 2023-08-07 00:14:54 +02:00
Simon Wisselink 019fe3f5e7 Add makefile entries for generating docs 2023-08-06 01:09:50 +02:00
Simon Wisselink 86b7d45399 Rewrote docs on filters and resources. 2023-08-06 01:09:31 +02:00
Simon Wisselink 4550bd8dfd Improved docs on compile checking and inheritance 2023-05-03 23:34:44 +02:00
Simon Wisselink 41962d5790 more docs 2023-05-02 01:17:12 +02:00
Simon Wisselink f7868b4ff1 Add docs for null coalescing 2023-05-01 23:57:53 +02:00
Simon Wisselink e99d2fae39 Added support for null coalescing operator
Fixes #882
2023-05-01 23:54:25 +02:00
Simon Wisselink 7fa8db3bc1 fixed error in the mkdocs TOC 2023-05-01 23:44:32 +02:00
Simon Wisselink b972bb5e72 updated changelog 2023-05-01 23:40:43 +02:00
Simon Wisselink 81cda9e363 Added full support and documentation for ternary operator.
Fixes #881
2023-05-01 23:25:42 +02:00
Simon Wisselink cea303d0ad Fixed markdown syntax. Fixes #879 2023-04-30 23:28:15 +02:00
Simon Wisselink d8ce15ee9b WIP docs (added page on config) 2023-03-24 11:52:18 +01:00
Simon Wisselink 1afd49e973 WIP on API docs 2023-03-10 23:49:41 +01:00
Simon Wisselink f4b94d4f03 Updated changelog and todo list 2023-03-09 23:17:09 +01:00
Simon Wisselink 5db8fd2533 Further WIP improving docs 2023-03-09 23:16:18 +01:00
Simon Wisselink 7a323b7345 Update code examples to use Smarty\Smarty and autoload instead of require_once calls and new Smarty 2023-02-06 15:18:47 +01:00
Simon Wisselink cf84802072 Finished improving designers docs 2023-02-06 14:56:06 +01:00
Simon Wisselink 4c6afd6b37 Improved another chunk of the designers docs 2023-02-06 14:55:07 +01:00
Simon Wisselink 833ba57d42 WIP improving the docs 2023-02-06 14:53:25 +01:00
Simon Wisselink 15d3968114 fixes to docs 2023-02-06 14:50:24 +01:00
Simon Wisselink 9c610e6e62 multiversion mkdocs config 2023-02-03 22:27:18 +01:00
Simon Wisselink 55ebb4efea Revert latest CI changes, we'll update docs by hand for now 2023-02-03 22:10:49 +01:00
Simon Wisselink ded3e12c1c add missing folder for unit tests 2023-02-03 17:56:49 +01:00
Simon Wisselink e6360694bf Add mkdocs for docs 2023-02-03 17:54:00 +01:00
Simon Wisselink 6c601e1b6c updated todo 2023-02-03 17:20:43 +01:00
Simon Wisselink 864643f2c9 remove additional calls to getCached() 2023-02-03 17:11:26 +01:00
Simon Wisselink 7408c18cdc WIP for performance improvements.
Removed $smarty->_current_file and $smarty->allow_ambiguous_resources properties, both unused. Removed public Source::filepath property.
Cached an Compiled files (and Exceptions) no longer rely on the filepath being set. Removed explicit tests for cached and compiled filenames. The exact implementation is not important. Added tests for compile_check property, fixing a file_exists check that would always be done on source template files, even when compile_check was true. Remove code duplication between Source en Config classes. Added a local $_smarty_current_dir to the generated code files for backwards compatability for {$smarty.current_dir}.
2023-02-03 15:50:31 +01:00
Simon Wisselink cd158566d0 Load compiled object in template constructor so it will be cached. 2023-01-31 14:48:41 +01:00
Simon Wisselink 0b2eae3137 Move all creating of templates to Smarty::createTemplate, adding a private property containing previously generated templates for speed. 2023-01-31 14:02:34 +01:00
Simon Wisselink 9e35cce3f8 Fix error in docs on prepend/append. Fixes #818. 2023-01-31 11:23:50 +01:00
Simon Wisselink 016c9ceb17 Generated <script> tags lo longer have deprecated type="text/javascript" or language="Javascript" attributes.
Fixes #815.
2023-01-31 11:17:41 +01:00
Simon Wisselink 6635a5e3fb Smarty no longer calls mb_internal_encoding() and doesn't check for deprecated mbstring.func_overload ini directive.
Fixes #480.
2023-01-31 10:53:10 +01:00
Simon Wisselink 1ef29b65ea move test methods because some other test methods rely on their relative positions 2023-01-31 10:52:56 +01:00
Simon Wisselink b4019b6023 Add test for registering compiler plugin with positional params. Fixes #164 2023-01-31 10:41:09 +01:00
Simon Wisselink 0962a34670 verify that native PHP functions cannot be used as a modifier and verify that an easy userland workaround exists. Fixes #813. 2023-01-31 10:10:32 +01:00
Simon Wisselink 18a8068df1 Throw compile error when using a modifier where it won't work. Fixes #526. 2023-01-31 09:54:44 +01:00
Simon Wisselink af316e661c 4.0.2 of smarty-lexer is released, use that 2023-01-29 21:57:10 +01:00
Simon Wisselink 8a2ed9446a Update composer packages cache key
Update composer packages cache key to trigger refresh on lexer
2023-01-28 10:44:01 +01:00
Simon Wisselink 39dad96601 Run make regardless of timestamps, so we are sure unit tests run with the generated PHP code, not with accidental human made changes to Lexer/Parser. 2023-01-26 13:03:04 +01:00
Simon Wisselink c47756b489 Re-organized rendering (read source / compile / cache) process to avoid circular dependencies. 2023-01-26 12:58:15 +01:00
Simon Wisselink 047b73d4a1 Pushed Lexers/Parsers into VCS again in order to be able to deliver using Packagist/Composer 2023-01-26 12:57:46 +01:00
Simon Wisselink cabcafc7ea Fix smarty-lexer dependency for the time being (remove direct ref to github) 2023-01-25 21:58:46 +01:00
Simon Wisselink a72f83d989 Fix smarty-lexer dependency for the time being 2023-01-25 21:58:04 +01:00
Simon Wisselink 9e2399b020 updated todo 2023-01-25 17:00:12 +01:00
Simon Wisselink 169cd924df Re-organized rendering (read source / compile / cache) process to avoid circular dependencies.
Deactivated merge_compiled_includes and the {include inline} attribute. They don't seem to do much in terms of performance, but we'll
have to check back.
2023-01-25 16:59:10 +01:00
Simon Wisselink 46dfed3837 Updated the changelog 2023-01-24 22:45:35 +01:00
Simon Wisselink 754db3b2e3 correct type of repository 2023-01-24 16:31:46 +01:00
Simon Wisselink 971c4d5158 Shouldnt need Github token now 2023-01-24 16:18:36 +01:00
Simon Wisselink a8cf56e4f4 attempt to load smarty-lexer directly from zip file 2023-01-24 16:18:09 +01:00
Simon Wisselink 45de28107a Update ci.yml 2023-01-24 16:12:53 +01:00
Simon Wisselink 79842c8baf Update ci.yml 2023-01-24 16:08:16 +01:00
Simon Wisselink 0e380a1748 fixes in source files 2023-01-24 16:05:38 +01:00
Simon Wisselink f53eb27450 Update ci.yml 2023-01-24 15:56:26 +01:00
Simon Wisselink a5a15b8b1e Update ci.yml 2023-01-24 15:54:15 +01:00
Simon Wisselink 262221f0b7 revise CI/CD workflows, bypass packagist for lexer 2023-01-24 15:49:44 +01:00
Simon Wisselink 344b3e3a31 Attempt to fix CI 2023-01-24 13:59:17 +01:00
Simon Wisselink b798362871 Run composer install before online test run 2023-01-24 12:57:01 +01:00
Simon Wisselink 1a8ee6ebda Merge branch 'master' into smarty5 2023-01-24 12:53:58 +01:00
Simon Wisselink 641678083b Add TODO list 2023-01-24 12:14:55 +01:00
Simon Wisselink ecfa4bfa16 Fixed getCachedContent 2023-01-24 12:09:47 +01:00
Simon Wisselink 9cc60f5e38 Convert isset and empty to modifiercomilers, and smooth the error handling to fix unit tests. 2023-01-24 12:01:20 +01:00
Simon Wisselink 431d77505f Fixed all scope assignment bugs 2023-01-24 10:16:00 +01:00
Simon Wisselink c5f555eed4 Drop a unit tests bc we no longer support direct access to PHP-functinos such as sin() 2023-01-23 16:59:52 +01:00
Simon Wisselink 2cf658c9c3 Fix function call compilation using {functionname} syntax for in-template defined functions. 2023-01-23 16:56:42 +01:00
Simon Wisselink ecac24d073 Fixed bug in {include} variable assignment and removed some unused/unrequired code 2023-01-23 16:40:27 +01:00
Simon Wisselink 34a0a2876b Fix major {include} bug 2023-01-23 15:56:26 +01:00
Simon Wisselink 3922c1eb1e Fixed the {if} failures. 2023-01-23 15:34:29 +01:00
Simon Wisselink 68c59e6627 Fix all foreach unit tests 2023-01-23 15:16:45 +01:00
Simon Wisselink ad2703dd75 Handle BC registered compilers and missed parameters for openTag and closeTag. 2023-01-23 12:08:36 +01:00
Simon Wisselink f1c3ac4395 Fixed all inheritance issues 2023-01-23 11:45:29 +01:00
Simon Wisselink 7c02bb9a63 Fix inhertiance implementation for $smarty.block.child 2023-01-23 08:47:49 +01:00
Simon Wisselink 4bbe94f4e0 Removed the undocumented {block_parent} and {parent} alternatives to {$smarty.block.parent}
and {block_child} and {child} alternatives to {$smarty.block.child}
2023-01-22 23:01:05 +01:00
Simon Wisselink bdb379d8fb Simply the "isFresh" method by not including the first param anymore. Fix a couple of unit tests by respecting tag_nocache set by nocache vars used in a tag. 2023-01-22 22:44:45 +01:00
Simon Wisselink 2d2d052557 Fix default plugin handler 2023-01-21 00:03:08 +01:00
Simon Wisselink f1f3874780 Made exception msgs exactly the same again, fixing some unit tests 2023-01-20 23:45:27 +01:00
Simon Wisselink 4ea8838d3b Fix testRegisterCompilerFunction by parsing argument correctly. 2023-01-20 23:42:08 +01:00
Simon Wisselink 03430c4f94 Fixed block append/prepend functionality 2023-01-20 23:16:41 +01:00
Simon Wisselink 2fbf67b32e Moved handling of smarty.block.* to special compilers, because they aren't real tags. Organized tag-stack handling in compiler, unified nocache handling in compiler. 2023-01-20 17:22:00 +01:00
Simon Wisselink 390f34318d Fixed cacheability of block plugins. 2023-01-19 23:29:10 +01:00
Simon Wisselink 27dd3e4c57 Fix function caching function name 2023-01-19 22:35:03 +01:00
Simon Wisselink 41c8bd3035 @var integer > @var int for vsCode 2023-01-19 22:32:06 +01:00
Simon Wisselink 38cad9723e Fix searchParents parameter, fixing GetTemplateVarsTest 2023-01-19 22:30:16 +01:00
Simon Wisselink f5b432dea4 Fixed scope in variable assignments in included and extended templates, fixed dependencies for testing freshness of caches. Added some unit tests and fixed a class reference to pass some more tests. 2023-01-13 23:29:05 +01:00
Simon Wisselink b02061878f Update test runners: no longer support PHP7.1, add PHP8.2 2023-01-13 23:28:18 +01:00
Simon Wisselink 5c74dc4a83 Replaced a bunch of direct property access with getters/setters. 2023-01-13 16:55:15 +01:00
Simon Wisselink 3be63a3418 Removed unneeded magic setters/getters/destructors and the like. 2023-01-13 15:56:25 +01:00
Simon Wisselink cdf1ed2a50 Simplified the (no)caching architecture by:
- removing support for $cache_attrs for registered plugins,
- removing the undocumented {make_nocache} tag and the deprecated {insert} tag and associated code
- removing support for a compile_id property on include tags.

Fixes a bug in extends: resources by propagating the nocache-hashes between a master template and it's subtemplates in \Smarty\Template::_subTemplateRender. This might need further improvement.
2023-01-13 15:47:57 +01:00
Simon Wisselink e0f2c36d4d converted 3 public properties on Template into getters/setters. unified Template creation code. Provided a getter/setter for the has_nocache_code property. Removed the useless DataObject class. Fixed a few tests. Removed the variable-allow-php-templates property from the docs. 2023-01-13 00:04:08 +01:00
Simon Wisselink 541f0821f0 Replace direct access to inheritance property on Template object by proper getter. 2023-01-12 10:11:10 +01:00
Simon Wisselink 536721d457 Removed the allowUndefinedVars check from the smarty error handlers, because undefined vars no longer throw an error, unless smarty->error_unassigned is set to true. 2023-01-12 09:59:10 +01:00
Simon Wisselink 577f910e49 removed phpplugin, removed now unused uncompiled handler and all checks for this, fixed a refactorbug in InheritanceRuntime. Moved getRenderedTemplateCode method to Smarty\Template. Renamed Cache en Compiled base class to GeneratedPhpFile for more clarity and distinction from Resource classes. Inlined Cached::create into its only caller. Some other minor improvements. Removed php7.1 CI tests. 2023-01-11 23:33:12 +01:00
Simon Wisselink 1fe5050a04 Fix configfile tests 2023-01-11 13:05:42 +01:00
Simon Wisselink 22ce23b47b Made variable scoping more sensible 2023-01-11 11:22:24 +01:00
Simon Wisselink ad245ccd0c Fixed minor unit tests 2023-01-11 00:00:07 +01:00
Simon Wisselink 51075e0421 WIP fixing the complicated variables scopes architecture. Right now more tests are failing than before... :( 2023-01-10 23:49:33 +01:00
Simon Wisselink 3d10630510 WIP rewriting variable scopes 2023-01-10 17:35:34 +01:00
Simon Wisselink 5052ce0d88 WIP 2023-01-10 14:54:21 +01:00
Simon Wisselink 9651dafbce WIP replacing direct access tpl_vars with proper getter/setters. 2023-01-10 14:46:33 +01:00
Simon Wisselink b424657fd9 Fix bug in calling BC function handlers. 2023-01-10 14:45:58 +01:00
Simon Wisselink 9016dd9908 Added strlen function, fixing some unit tests 2023-01-09 11:54:13 +01:00
Simon Wisselink e124f71dd8 Fixed issue related to scoping of left/right delimiter overrides 2023-01-09 11:25:09 +01:00
Simon Wisselink 34d5d6d024 Rewrote global static global_tpl_vars to getters/setters on Smarty class, fixing several test cases. Added a ::getValue() method to Variable. 2023-01-09 09:55:22 +01:00
Simon Wisselink c5de83b09f Fixed modifiercompiler handling multiple/chained modifiers 2023-01-09 09:53:15 +01:00
Simon Wisselink 861aafa92c 2 small fixes for unit tests 2023-01-07 23:45:59 +01:00
Simon Wisselink e1d395e140 Fixed stream resources 2023-01-07 23:22:58 +01:00
Simon Wisselink fd64cc688a Removed PHP functions and checks for the already removed php modifiers. Re-implemented functions as regular functions. Probably should compile these directly. 2023-01-07 23:06:47 +01:00
Simon Wisselink e595cd2a5d Fixed BC loading of resource pluging from dir and all ResourcePluginTest tests 2023-01-06 21:53:37 +01:00
Simon Wisselink b2e11ee2b8 Removed deprecated extends_recursion property and fix bug in CodeFrame compiler due to use of clone. 2023-01-06 21:43:48 +01:00
Simon Wisselink 1f87cebb93 Make DefaultExtension lazy load again. 2023-01-06 21:41:23 +01:00
Simon Wisselink 608a400e66 Fix scoping / global state problems in tests by using DI in Default Extension. Also removing a bunch of old fashioned phpdoc annotations that are superseded by namespaces. 2023-01-05 23:07:45 +01:00
Simon Wisselink f07e342d61 Removed now unneeded PHPunit annotations @run(Tests)InSeparateProcess, @preserveGlobalState and @backupStaticAttributes. Made CacheResourceTestCommon abstract to prevent the base class from running tests (and always failing). Unregister a previously registered stream wrapper. Fixes a lot of tests. 2023-01-05 23:06:02 +01:00
Simon Wisselink 576bd4cc01 Removed support for PHP include path, and removed the ::loadPlugin method. 2023-01-05 21:58:29 +01:00
Simon Wisselink e89a3dda49 Implemented the DefaultHandlerBlockCompiler, made the dependencies of the template compiler into properties, fixed a couple of unit tests 2023-01-05 11:18:42 +01:00
Simon Wisselink 2b71415d1f minor fixes 2023-01-04 23:48:45 +01:00
Simon Wisselink 3cc61133a3 Fix code duplication in block compilers and fix (most) BlockPluginTests. Default plugin handler blocks still need fixing. 2023-01-04 23:45:57 +01:00
Simon Wisselink 216347b4ff Introduce formatParamsArray method for recurring code fragment 2023-01-04 14:42:30 +01:00
Simon Wisselink 14bbffd584 move runPluginFromDefaultHandler to new Runtime class 2023-01-04 13:19:25 +01:00
Simon Wisselink 41054cfb05 Fixed DefaultPluginHandlerTest for function plugins (blocks still break) 2023-01-04 12:16:10 +01:00
Simon Wisselink 16c7fe1d4f Fixed setfilter 2023-01-03 22:03:43 +01:00
Simon Wisselink 3fccb54093 Fixed CacheResource implementation and tests 2023-01-03 17:10:02 +01:00
Simon Wisselink 32df4c6467 Fix CustomResourceAmbiguousTest 2023-01-03 15:02:58 +01:00
Simon Wisselink 98ad1a13af Fixed TemplateObject test 2023-01-03 14:20:40 +01:00
Simon Wisselink 9766aba66e filter tests passing 2023-01-03 14:12:36 +01:00
Simon Wisselink b9ecf115dd fixed pre/post/output filters and removed some old todo-comments 2023-01-02 23:26:36 +01:00
Simon Wisselink 60a56969dd WIP moving Smarty to PSR-4. 2023-01-02 00:49:38 +01:00
Simon Wisselink 6b9e2fadd1 Rewrote remaining plugins to PSR-4, plugins dir is now gone. 2022-12-25 14:02:15 +01:00
Simon Wisselink ab5705a90d Rewrote all default modifiers and functions from the plugins folder to PSR-4 classes 2022-12-24 23:38:13 +01:00
Simon Wisselink 57cff64869 Add makefile, PSR-4 ModifierCompilers 2022-12-23 14:03:05 +01:00
Simon Wisselink 4d66910e7f Entire src dir now PSR-4 compatible 2022-12-22 22:38:37 +01:00
Simon Wisselink f1e7b2d46f src/sysplugins/* to PSR-4 2022-12-22 21:50:01 +01:00
Simon Wisselink 0fc2b3726b src/Template/* to PSR-4 2022-12-22 21:23:22 +01:00
Simon Wisselink d88175de3e Refactored all _runtime_* by merging them into the proper classes or by transforming them into Runtime Extensions. 2022-12-22 15:43:20 +01:00
Simon Wisselink cfd8c08d09 smarty_internal_resource_* to PSR-4 2022-12-21 16:33:26 +01:00
Simon Wisselink b0db4705a0 Finished moving smarty_internal_method_* 2022-12-21 14:47:33 +01:00
Simon Wisselink 5cac5e42f1 WIP rewriting smarty_internal_method_* 2022-12-21 14:01:18 +01:00
Simon Wisselink 6ba059dea8 Rewrote all Compile and Compiler classes to PSR-4 2022-12-20 23:47:18 +01:00
Simon Wisselink 1524f11c8e finished rewriting all compile classes into PSR-4 2022-12-20 23:05:36 +01:00
Simon Wisselink 164a89a1fd WIP making compile classes PSR-4 2022-12-01 23:44:58 +01:00
Simon Wisselink d0319bdc87 Replace Smarty:: with symfony/polyfill-mbstring 2022-12-01 21:56:12 +01:00
Simon Wisselink 9a0d46f1bc WIP making compile classes PSR-4 2022-12-01 21:54:23 +01:00
Simon Wisselink 53fe73b9cc WIP making compile classes PSR-4 2022-12-01 21:53:05 +01:00
Simon Wisselink e54a53332f Removed autoload filters 2022-11-30 10:06:09 +01:00
Simon Wisselink 8b5540f4f3 More PSR4 rewriting 2022-11-30 00:25:27 +01:00
Simon Wisselink 91b6fdeb4e WIP converting code to PSR-4 2022-11-28 12:30:07 +01:00
46 changed files with 125 additions and 339 deletions
-11
View File
@@ -6,17 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Registered output filters wouldn't run [#899](https://github.com/smarty-php/smarty/issues/899)
- Use of negative numbers in {math} equations [#895](https://github.com/smarty-php/smarty/issues/895)
- Do not auto-html-escape custom function results [#906](https://github.com/smarty-php/smarty/issues/906)
- Fix case-sensitive tag names [#907](https://github.com/smarty-php/smarty/issues/907)
### Removed
- Removed `$smarty->registered_filters` array
## [5.0.0-rc1] - 2023-08-08
### Added
- Added support for PHP8.2
- Added a new way to extend Smarty functionality using `Smarty::addExtension()` or `Smarty::setExtensions()`. Please see the docs for more information.
-119
View File
@@ -1,119 +0,0 @@
# Contributing to Smarty
First off, thanks for taking the time to contribute! ❤️
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Tell a friend about it
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues
## I Have a Question
> If you want to ask a question, we assume that you have read the available [Documentation](https://smarty-php.github.io/smarty).
Before you ask a question, it is best to search for existing [Issues](https://github.com/smarty-php/smarty/issues) that might help you.
In case you have found a suitable issue and still need clarification, you can write your question in this issue.
It is also advisable to search the internet for answers first.
If you then still feel the need to ask a question and need clarification, we recommend the following:
- [Open an Issue](https://github.com/smarty-php/smarty/issues/new).
- Provide as much context as you can about what you're running into.
- Provide Smarty and PHP versions
We will then take care of the issue as soon as possible.
## I Want To Contribute
> ### Legal Notice
> When contributing to this project, you must agree that you have authored 100% of the content,
> that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
### Reporting Bugs
#### Before Submitting a Bug Report
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to
investigate carefully, collect information and describe the issue in detail in your report. Please complete the
following steps in advance to help us fix any potential bug as fast as possible.
- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side. (Make sure that you have read the [documentation](https://smarty-php.github.io/smarty). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/smarty-php/smarty/issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
- For an Exception: please provide the Stack trace
- OS (Windows, Linux, macOS)
- PHP version
- Smarty version
- A minimal snippet of (your) code that triggers the bug
- Expected output versus actual output
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?
#### How Do I Submit a Good Bug Report?
> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public.
> For sensitive bugs, please see [SECURITY.md](SECURITY.md).
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
- Open an [Issue](https://github.com/smarty-php/smarty/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.
Once it's filed:
- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be implemented by someone.
### Suggesting Enhancements
This section guides you through submitting an enhancement suggestion for CONTRIBUTING.md, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
#### Before Submitting an Enhancement
- Make sure that you are using the latest version.
- Read the [documentation](https://smarty-php.github.io/smarty) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/smarty-php/smarty/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
#### How Do I Submit a Good Enhancement Suggestion?
Enhancement suggestions are tracked as [GitHub issues](https://github.com/smarty-php/smarty/issues).
- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux.
- **Explain why this enhancement would be useful** to most CONTRIBUTING.md users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
### Improving The Documentation
The [docs](docs/index.md) are written in markdown, configured in [mkdocs.yml](mkdocs.yml) and published
to [GitHub pages](https://smarty-php.github.io/smarty) using [mkdocs](https://www.mkdocs.org/) and [mike](https://github.com/jimporter/mike).
To preview the docs while you are writing, run:
```bash
mkdocs serve
```
This should launch a local web server and give you a link to open in your browser.
When you are finished, commit your changes and provide a [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
#### Publishing the docs
If you are a maintainer, you can publish the document using [mike](https://github.com/jimporter/mike). Make sure you provide the correct version.
```bash
mike deploy 5.x
```
## Attribution
This guide is based on the **contributing.md**. [Make your own](https://contributing.md/)!
+6
View File
@@ -3,6 +3,12 @@ all: lexers parsers
lexers: src/Lexer/ConfigfileLexer.php src/Lexer/TemplateLexer.php
parsers: src/Parser/ConfigfileParser.php src/Parser/TemplateParser.php
docs:
mike deploy 5.0
test-docs:
mkdocs serve
src/Lexer/ConfigfileLexer.php: src/Lexer/ConfigfileLexer.plex
php ./utilities/make-lexer.php src/Lexer/ConfigfileLexer.plex src/Lexer/ConfigfileLexer.php
+3 -3
View File
@@ -2,13 +2,13 @@
## Supported Versions
Smarty currently supports the latest minor version of Smarty 4 and Smarty 5.
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4.
| Version | Supported |
|---------|--------------------|
| 5.0.x | :white_check_mark: |
| 4.3.x | :white_check_mark: |
| < 4.3 | :x: |
| 3.1.x | :white_check_mark: |
| < 3.1 | :x: |
## Reporting a Vulnerability
+1 -33
View File
@@ -5,7 +5,7 @@ services:
context: .
dockerfile: ./utilities/testrunners/php72/Dockerfile
volumes:
- smarty-code:/app
- .:/app
working_dir: /app
php72:
extends:
@@ -37,35 +37,3 @@ services:
service: base
build:
dockerfile: ./utilities/testrunners/php82/Dockerfile
volumes:
smarty-code:
x-mutagen:
sync:
defaults:
symlink:
mode: "posix-raw"
ignore:
vcs: true
paths:
- ".docker"
- ".env.docker"
- ".bundles"
- "docker-compose.yml"
- ".idea"
- ".DS_Store"
mode: "two-way-resolved"
configurationBeta:
permissions:
defaultOwner: "id:${APP_USER_ID}"
defaultGroup: "id:${APP_GROUP_ID}"
defaultFileMode: 0666
defaultDirectoryMode: 0755
permissions:
defaultOwner: "id:${APP_USER_ID}"
defaultGroup: "id:${APP_GROUP_ID}"
smarty-code:
alpha: "."
beta: "volume://smarty-code"
+1 -1
View File
@@ -22,7 +22,7 @@ footer.tpl:
<small>Copyright {$companyName|escape}</small>
```
Smarty will apply the [escape modifier](../../designers/language-modifiers/language-modifier-escape.md)
Smarty will apply the [escape modifier](../designers/language-modifiers/language-modifier-escape.md)
to the value assigned to the variable
`companyName` and replace `{$companyName|escape}` with the result.
+7 -6
View File
@@ -27,7 +27,7 @@ Intro = """This is a value that spans more
```
Values of [config file variables](../../designers/language-variables/language-config-variables.md) can be in
Values of [config file variables](./language-variables/language-config-variables.md) can be in
quotes, but not necessary. You can use either single or double quotes.
If you have a value that spans more than one line, enclose the entire
value with triple quotes \("""\). You can put comments into config
@@ -81,8 +81,9 @@ $smarty->setConfigOverwrite(false);
When config overwrite is disabled, Smarty will create arrays of config file variables when it encounters
multiple entries with the same name.
See also [`{config_load}`](../../designers/language-builtin-functions/language-function-config-load.md),
[`$default_config_handler_func`](../../programmers/api-variables/variable-default-config-handler-func.md),
[`getConfigVars()`](../../programmers/api-functions/api-get-config-vars.md),
[`clearConfig()`](../../programmers/api-functions/api-clear-config.md) and
[`configLoad()`](../../programmers/api-functions/api-config-load.md)
See also [`{config_load}`](./language-builtin-functions/language-function-config-load.md),
[`$config_overwrite`](../programmers/api-variables/variable-config-overwrite.md),
[`$default_config_handler_func`](../programmers/api-variables/variable-default-config-handler-func.md),
[`getConfigVars()`](../programmers/api-functions/api-get-config-vars.md),
[`clearConfig()`](../programmers/api-functions/api-clear-config.md) and
[`configLoad()`](../programmers/api-functions/api-config-load.md)
+1 -1
View File
@@ -55,7 +55,7 @@ You can restrict the methods and properties that can be accessed by
listing them in an array as the third registration parameter.
By default, parameters passed to objects through the templates are
passed the same way [custom tags](../../designers/language-custom-functions/index.md) get
passed the same way [custom functions](../../designers/language-custom-functions/index.md) get
them. An associative array is passed as the first parameter, and the
smarty object as the second. If you want the parameters passed one at a
time for each argument like traditional object parameter passing, set
@@ -14,7 +14,7 @@ A simple Smarty template could look like this:
All Smarty template tags are enclosed within delimiters. By default
these are `{` and `}`, but they can be
[changed](../../designers/language-basic-syntax/language-escaping.md).
[changed](../../programmers/api-variables/variable-left-delimiter.md).
For the examples in this manual, we will assume that you are using the
default delimiters. In Smarty, all content outside of delimiters is
@@ -22,12 +22,12 @@ displayed as static content, or unchanged. When Smarty encounters
template tags, it attempts to interpret them, and displays the
appropriate output in their place.
The basic components of the Smarty syntax are:
The basis components of the Smarty syntax are:
- [Comments](language-syntax-comments.md)
- [Variables](language-syntax-variables.md)
- [Operators](language-syntax-operators.md)
- [Tags](language-syntax-tags.md)
- [Functions](language-syntax-functions.md)
- [Attributes](language-syntax-attributes.md)
- [Quotes](language-syntax-quotes.md)
- [Escaping](language-escaping.md)
@@ -45,7 +45,8 @@ variables.
Smarty's default delimiters { and } cleanly represent presentational
content. However, if another set of delimiters suit your needs better,
you can change them with Smarty's
`setLeftDelimiter()` and `setRightDelimiter()` methods.
[`$left_delimiter`](../../programmers/api-variables/variable-left-delimiter.md) and
[`$right_delimiter`](../../programmers/api-variables/variable-right-delimiter.md) values.
> **Note**
>
@@ -56,8 +57,8 @@ you can change them with Smarty's
```php
<?php
$smarty->setLeftDelimiter('<!--{');
$smarty->setRightDelimiter('}-->');
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
$smarty->assign('foo', 'bar');
$smarty->assign('name', 'Albert');
@@ -1,6 +1,6 @@
# Attributes
Most of the [tags](./language-syntax-tags.md) take attributes that
Most of the [functions](./language-syntax-functions.md) take attributes that
specify or modify their behavior. Attributes to Smarty functions are
much like HTML attributes. Static values don't have to be enclosed in
quotes, but it is required for literal strings. Variables with or
@@ -1,7 +1,7 @@
# Comments
Template comments are surrounded by asterisks, and that is surrounded by
the [delimiter](../../designers/language-basic-syntax/language-escaping.md) tags like so:
the [delimiter](../../programmers/api-variables/variable-left-delimiter.md) tags like so:
## Examples
@@ -1,4 +1,4 @@
# Tags
# Functions
Every Smarty tag either prints a [variable](./language-syntax-variables.md) or
invokes some sort of function. These are processed and displayed by
@@ -31,8 +31,8 @@ within delimiters like so: `{funcname attr1="val1" attr2="val2"}`.
[`{strip}`](../language-builtin-functions/language-function-strip.md). There should be no need to
change or modify them.
- Custom tags are **additional** tags implemented via
[plugins](../../api/extending/introduction.md). They can be modified to your liking, or you can
- Custom functions are **additional** functions implemented via
[plugins](../../programmers/plugins.md). They can be modified to your liking, or you can
create new ones. [`{html_options}`](../language-custom-functions/language-function-html-options.md)
is an example of a custom function.
@@ -4,7 +4,7 @@ Smarty comes with several built-in functions. These built-in functions
are the integral part of the smarty template engine. They are compiled
into corresponding inline PHP code for maximum performance.
You cannot create your own [custom tags](../language-custom-functions/index.md) with the same name; and you
You cannot create your own [custom functions](../language-custom-functions/index.md) with the same name; and you
should not need to modify the built-in functions.
A few of these functions have an `assign` attribute which collects the
@@ -2,7 +2,7 @@
`{block}` is used to define a named area of template source for template
inheritance. For details see section of [Template
Inheritance](../../api/inheritance.md).
Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md).
The `{block}` template source area of a child template will replace the
corresponding areas in the parent template(s).
@@ -195,7 +195,7 @@ The result would look like
```
See also [Template
Inheritance](../../api/inheritance.md),
Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md),
[`$smarty.block.parent`](../language-variables/language-variables-smarty.md#smartyblockparent-languagevariablessmartyblockparent),
[`$smarty.block.child`](../language-variables/language-variables-smarty.md#smartyblockchild-languagevariablessmartyblockchild), and
[`{extends}`](./language-function-extends.md)
@@ -2,7 +2,7 @@
`{extends}` tags are used in child templates in template inheritance for
extending parent templates. For details see section of [Template
Inheritance](../../api/inheritance.md).
Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md).
- The `{extends}` tag must be on the first line of the template.
@@ -10,7 +10,7 @@ Inheritance](../../api/inheritance.md).
tag it may contain only `{block}` tags. Any other template content
is ignored.
- Use the syntax for [template resources](../../api/resources.md) to extend files
- Use the syntax for [template resources](../../programmers/resources.md) to extend files
outside the [`$template_dir`](../../programmers/api-variables/variable-template-dir.md) directory.
## Attributes
@@ -33,5 +33,5 @@ Inheritance](../../api/inheritance.md).
{extends 'parent.tpl'} {* short-hand *}
```
See also [Template Inheritance](../../api/inheritance.md)
See also [Template Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md)
and [`{block}`](./language-function-block.md).
@@ -41,7 +41,7 @@ available within the included template.
is useful to return values from the included template to the
including template.
- Use the syntax for [template resources](../../api/resources.md) to `{include}`
- Use the syntax for [template resources](../../programmers/resources.md) to `{include}`
files outside of the [`$template_dir`](../../programmers/api-variables/variable-template-dir.md)
directory.
@@ -85,11 +85,11 @@ The template above includes the example `links.tpl` below
```smarty
<div id="box">
<h3>{$title}</h3>
<h3>{$title}{/h3>
<ul>
{foreach from=$links item=l}
.. do stuff ...
{/foreach}
</foreach}
</ul>
</div>
```
@@ -183,5 +183,5 @@ current template.
{include file="$style_dir/$module.$view.tpl"}
```
See also [template resources](../../api/resources.md) and
See also [template resources](../../programmers/resources.md) and
[componentized templates](../../appendixes/tips.md#componentized-templates).
@@ -4,7 +4,7 @@
template delimiters, by default **{** and **}**. You can also use
[`{literal}{/literal}`](./language-function-literal.md) to escape blocks of
text eg Javascript or CSS. See also the complementary
[`{$smarty.ldelim}`](../../designers/language-basic-syntax/language-escaping.md).
[`{$smarty.ldelim}`](../../programmers/api-variables/variable-left-delimiter.md).
```smarty
{* this will print literal delimiters out of the template *}
@@ -3,7 +3,7 @@
`{literal}` tags allow a block of data to be taken literally. This is
typically used around Javascript or stylesheet blocks where {curly
braces} would interfere with the template
[delimiter](../../designers/language-basic-syntax/language-escaping.md) syntax. Anything within
[delimiter](../../programmers/api-variables/variable-left-delimiter.md) syntax. Anything within
`{literal}{/literal}` tags is not interpreted, but displayed as-is. If
you need template tags embedded in a `{literal}` block, consider using
[`{ldelim}{rdelim}`](./language-function-ldelim.md) to escape the individual
@@ -326,10 +326,10 @@ The template to output the database result in a HTML table
```smarty
<table>
<tr><th>&nbsp;</th><th>Name</th><th>Home</th><th>Cell</th><th>Email</th></tr>
<tr><th>&nbsp;</th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
{section name=co loop=$contacts}
<tr>
<td><a href="view.php?id={$contacts[co].id}">view</a></td>
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
<td>{$contacts[co].name}</td>
<td>{$contacts[co].home}</td>
<td>{$contacts[co].cell}</td>
@@ -465,7 +465,7 @@ header block every five rows.
<table>
{section name=co loop=$contacts}
{if $smarty.section.co.iteration is div by 5}
<tr><th>&nbsp;</th><th>Name</th><th>Home</th><th>Cell</th><th>Email</th></tr>
<tr><th>&nbsp;</th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
{/if}
<tr>
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
@@ -1,4 +1,4 @@
# Custom Tags
# Custom Functions
Smarty comes with several custom plugin functions that you can use in
the templates.
@@ -22,7 +22,7 @@ output to the template.
> templates.
>
> - Evaluated variables are compiled on every invocation, the compiled
> versions are not saved! However, if you have [caching](../../api/caching/basics.md)
> versions are not saved! However, if you have [caching](../../programmers/caching.md)
> enabled, the output will be cached with the rest of the template.
>
> - If the content to evaluate doesn't change often, or is used
@@ -28,7 +28,7 @@ ftp and display the contents.
> If security is enabled, and you are fetching a file from the local
> file system, `{fetch}` will only allow files from within the
> `$secure_dir` path of the security policy. See the
> [Security](../../api/security.md) section for details.
> [Security](../../programmers/advanced-features/advanced-features-security.md) section for details.
- If the `assign` attribute is set, the output of the `{fetch}`
function will be assigned to this template variable instead of being
@@ -20,7 +20,7 @@ automatically calculated from the image file if they are not supplied.
from. If not given, the web server's document root
`$_ENV['DOCUMENT_ROOT']` is used as the base. If security is
enabled, then the image must be located in the `$secure_dir` path of
the security policy. See the [Security](../../api/security.md)
the security policy. See the [Security](../../programmers/advanced-features/advanced-features-security.md)
section for details.
- `href` is the href value to link the image to. If link is supplied,
@@ -37,7 +37,7 @@ automatically calculated from the image file if they are not supplied.
>
> `{html_image}` requires a hit to the disk to read the image and
> calculate the height and width. If you don't use template
> [caching](../../api/caching/basics.md), it is generally better to avoid `{html_image}`
> [caching](../../programmers/caching.md), it is generally better to avoid `{html_image}`
> and leave image tags static for optimal performance.
## Examples
@@ -1,6 +1,6 @@
# {textformat}
`{textformat}` is a block tag used to
`{textformat}` is a [block function](../../programmers/plugins/plugins-block-functions.md) used to
format text. It basically cleans up spaces and special characters, and
formats paragraphs by wrapping at a boundary and indenting lines.
+2 -2
View File
@@ -1,7 +1,7 @@
# Variable Modifiers
Variable modifiers can be applied to
[variables](../language-variables/index.md), [custom tags](../language-custom-functions/index.md)
[variables](../language-variables/index.md), [custom functions](../language-custom-functions/index.md)
or strings. To apply a modifier,
specify the value followed by a `|` (pipe) and the modifier name. A
modifier may accept additional parameters that affect its behavior.
@@ -102,4 +102,4 @@ These parameters follow the modifier name and are separated by a `:`
See also [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md), [combining
modifiers](../language-combining-modifiers.md). and [extending smarty with
plugins](../../api/extending/introduction.md)
plugins](../../programmers/plugins.md)
+2 -2
View File
@@ -8,11 +8,11 @@ variable depends on what symbol it is prefixed or enclosed within.
- [{$smarty} reserved variable](language-variables-smarty.md)
Variables in Smarty can be either displayed directly or used as
arguments for [tags](../language-basic-syntax/language-syntax-tags.md),
arguments for [functions](../language-basic-syntax/language-syntax-functions.md),
[attributes](../language-basic-syntax/language-syntax-attributes.md) and
[modifiers](../language-modifiers/index.md), inside conditional expressions, etc.
To print a variable, simply enclose it in the
[delimiters](../../designers/language-basic-syntax/language-escaping.md) so that it is the only thing
[delimiters](../../programmers/api-variables/variable-left-delimiter.md) so that it is the only thing
contained between them.
```smarty
@@ -110,7 +110,7 @@ zaphod@slartibartfast.example.com<br />
## Objects
Properties of [objects](../../api/variables/objects.md) assigned from PHP
Properties of [objects](../../programmers/advanced-features/advanced-features-objects.md) assigned from PHP
can be referenced by specifying the property name after the `->` symbol.
```smarty
@@ -138,12 +138,12 @@ Returns the version of Smarty the template was compiled with.
## {$smarty.block.child}
Returns block text from child template. See [Template
inheritance](../../api/inheritance.md).
inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md).
## {$smarty.block.parent}
Returns block text from parent template. See [Template
inheritance](../../api/inheritance.md)
inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md)
## {$smarty.ldelim}, {$smarty.rdelim}
+17 -16
View File
@@ -1,35 +1,36 @@
# Features
Features
=======
Some of Smarty's features:
- It is extremely fast.
- It is efficient since the PHP parser does the dirty work.
- No template parsing overhead, only compiles once.
- It is smart about recompiling only the
- It is smart about [recompiling](#variable.compile.check) only the
template files that have changed.
- You can easily create your own custom
[tags](api/extending/tags.md) and [modifiers](api/extending/modifiers.md), so the template language is
[functions](#language.custom.functions) and [variable
modifiers](#language.modifiers), so the template language is
extremely extensible.
- Configurable template [{delimiter}](designers/language-basic-syntax/language-escaping.md) tag
- Configurable template [{delimiter}](#variable.left.delimiter) tag
syntax, so you can use `{$foo}`, `{{$foo}}`, `<!--{$foo}-->`, etc.
- The [`{if}..{elseif}..{else}..{/if}`](designers/language-builtin-functions/language-function-if.md)
- The [`{if}..{elseif}..{else}..{/if}`](#language.function.if)
constructs are passed to the PHP parser, so the `{if...}` expression
syntax can be as simple or as complex an evaluation as you like.
- Allows unlimited nesting of
[`sections`](designers/language-builtin-functions/language-function-section.md), `if's` etc.
- Built-in [caching](api/caching/basics.md) support
- Arbitrary [template](api/resources.md) sources
- [Template Inheritance](api/inheritance.md) for
[`sections`](#language.function.section), `if's` etc.
- Built-in [caching](#caching) support
- Arbitrary [template](#resources) sources
- [Template Inheritance](#advanced.features.template.inheritance) for
easy management of template content.
- [Plugin](api/extending/introduction.md) architecture
- [Plugin](#plugins) architecture
## Separation of presentation from application code
- This means templates can certainly contain logic under the condition
that it is for presentation only. Things such as
[including](designers/language-builtin-functions/language-function-include.md) other templates,
[alternating](designers/language-custom-functions/language-function-cycle.md) table row colors,
[upper-casing](designers/language-modifiers/language-modifier-upper.md) a variable,
[looping](designers/language-builtin-functions/language-function-foreach.md) over an array of data and
[including](./designers/language-builtin-functions/language-function-include.md) other templates,
[alternating](./designers/language-custom-functions/language-function-cycle.md) table row colors,
[upper-casing](./designers/language-modifiers/language-modifier-upper.md) a variable,
[looping](./designers/language-builtin-functions/language-function-foreach.md) over an array of data and
rendering it are examples of presentation logic.
- This does not mean however that Smarty forces a separation of
business and presentation logic. Smarty has no knowledge of which is
@@ -60,7 +61,7 @@ inheritance, instead of including other templates we maintain our
templates as single pages. We can then manipulate blocks of content
within by inheriting them. This makes templates intuitive, efficient and
easy to manage. See
[Template Inheritance](api/inheritance.md)
[Template Inheritance](./programmers/advanced-features/advanced-features-template-inheritance.md)
for more info.
## Why not use XML/XSLT syntax?
+1 -3
View File
@@ -79,8 +79,6 @@ $smarty->setCacheDir('/some/cache/dir');
$smarty->testInstall();
```
## Basic usage
Now, let's create the `index.tpl` file that Smarty will display. This
needs to be located in the [`$template_dir`](./programmers/api-variables/variable-template-dir.md).
@@ -167,7 +165,7 @@ class My_GuestBook extends Smarty {
Now, we can use `My_GuestBook` instead of `Smarty` in our scripts:
```php
<?php
$smarty = new My_GuestBook();
$smarty = new Smarty_GuestBook();
$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');
```
+3 -3
View File
@@ -13,13 +13,13 @@ newspaper article.
- The article `$headline`, `$tagline`, `$author` and `$body` are
content elements, they contain no information about how they will be
presented. They are [passed](getting-started.md#basic-usage) into Smarty by the
presented. They are [passed](#api.assign) into Smarty by the
application.
- Then the template designer edits the templates and uses a
combination of HTML tags and [template tags](designers/language-basic-syntax/language-syntax-tags.md)
combination of HTML tags and [template tags](#language.basic.syntax)
to format the presentation of these
[variables](designers/language-basic-syntax/language-syntax-variables.md) with elements such as
[variables](#language.syntax.variables) with elements such as
tables, div\'s, background colors, font sizes, style sheets, svg
etc.
@@ -0,0 +1,8 @@
\$left\_delimiter {#variable.left.delimiter}
=================
This is the left delimiter used by the template language. Default is
`{`.
See also [`$right_delimiter`](#variable.right.delimiter) and [escaping
smarty parsing](#language.escaping) .
@@ -0,0 +1,8 @@
\$right\_delimiter {#variable.right.delimiter}
==================
This is the right delimiter used by the template language. Default is
`}`.
See also [`$left_delimiter`](#variable.left.delimiter) and [escaping
smarty parsing](#language.escaping).
+4 -4
View File
@@ -1,17 +1,17 @@
#!/bin/bash
if [[ "$1" =~ ^5\.[0-9\.]+(-rc[0-9]+)?$ ]]; then
if [[ "$1" =~ ^4\.[0-9\.-rc]+$ ]]; then
printf 'Creating release %s\n' "$1"
else
echo "Invalid version number: $1. This script can only make v5.x.x releases."
echo "Invalid version number: $1. This script can only make v4.x.x releases."
exit 1;
fi
git checkout -b "release/$1"
sed -i "s/## \\[Unreleased\\]/## \\[Unreleased\\]\\n\\n## \\[$1\\] - $(date +%Y-%m-%d)/" CHANGELOG.md
sed -i "s/const SMARTY_VERSION = '[^']\+';/const SMARTY_VERSION = '$1';/" src/Smarty.php
sed -i "s/const SMARTY_VERSION = '[^']\+';/const SMARTY_VERSION = '$1';/" libs/Smarty.class.php
git add CHANGELOG.md src/Smarty.php
git add CHANGELOG.md libs/Smarty.class.php
git commit -m "version bump"
git checkout master
+3 -3
View File
@@ -33,7 +33,7 @@ nav:
- Comments: 'designers/language-basic-syntax/language-syntax-comments.md'
- Variables: 'designers/language-basic-syntax/language-syntax-variables.md'
- Operators: 'designers/language-basic-syntax/language-syntax-operators.md'
- Tags: 'designers/language-basic-syntax/language-syntax-tags.md'
- Functions: 'designers/language-basic-syntax/language-syntax-functions.md'
- Attributes: 'designers/language-basic-syntax/language-syntax-attributes.md'
- Quotes: 'designers/language-basic-syntax/language-syntax-quotes.md'
- 'Escaping Smarty parsing': 'designers/language-basic-syntax/language-escaping.md'
@@ -70,7 +70,7 @@ nav:
- 'upper': 'designers/language-modifiers/language-modifier-upper.md'
- 'wordwrap': 'designers/language-modifiers/language-modifier-wordwrap.md'
- 'Combining Modifiers': 'designers/language-combining-modifiers.md'
- 'Builtin Tags':
- 'Builtin Functions':
- 'Introduction': 'designers/language-builtin-functions/index.md'
- '{append}': 'designers/language-builtin-functions/language-function-append.md'
- '{assign}': 'designers/language-builtin-functions/language-function-assign.md'
@@ -93,7 +93,7 @@ nav:
- '{setfilter}': 'designers/language-builtin-functions/language-function-setfilter.md'
- '{strip}': 'designers/language-builtin-functions/language-function-strip.md'
- '{while}': 'designers/language-builtin-functions/language-function-while.md'
- 'Custom Tags':
- 'Custom Functions':
- 'Introduction': 'designers/language-custom-functions/index.md'
- '{counter}': 'designers/language-custom-functions/language-function-counter.md'
- '{cycle}': 'designers/language-custom-functions/language-function-cycle.md'
+6 -8
View File
@@ -5,11 +5,9 @@
# - ./run-tests-for-all-php-versions.sh --group 20221124
# - ./run-tests-for-all-php-versions.sh --exclude-group slow
COMPOSE_CMD="mutagen-compose"
$COMPOSE_CMD run --rm php72 ./run-tests.sh $@ && \
$COMPOSE_CMD run --rm php74 ./run-tests.sh $@ && \
$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 $@
docker-compose run php72 ./run-tests.sh $@ && \
docker-compose run php73 ./run-tests.sh $@ && \
docker-compose run php74 ./run-tests.sh $@ && \
docker-compose run php80 ./run-tests.sh $@ && \
docker-compose run php81 ./run-tests.sh $@ && \
docker-compose run php82 ./run-tests.sh $@
+3 -6
View File
@@ -464,7 +464,7 @@ class Template extends BaseCompiler {
public function compileTag($tag, $args, $parameter = []) {
$this->prefixCodeStack[] = $this->prefix_code;
$this->prefix_code = [];
$result = $this->compileTag2($tag, $args, $parameter);
$result = $this->compileTag2(strtolower($tag), $args, $parameter);
$this->prefix_code = array_merge($this->prefix_code, array_pop($this->prefixCodeStack));
return $result;
}
@@ -591,9 +591,6 @@ class Template extends BaseCompiler {
* @return ?\Smarty\Compile\CompilerInterface tag compiler object or null if not found or untrusted by security policy
*/
public function getTagCompiler($tag): ?\Smarty\Compile\CompilerInterface {
$tag = strtolower($tag);
$tag = strtolower($tag);
if (isset($this->smarty->security_policy) && !$this->smarty->security_policy->isTrustedTag($tag, $this)) {
return null;
@@ -1117,7 +1114,7 @@ class Template extends BaseCompiler {
}
}
// call to function previously defined by {function} tag
// call to function previousely defined by {function} tag
if ($this->canCompileTemplateFunctionCall($tag)) {
if (!empty($parameter['modifierlist'])) {
@@ -1143,7 +1140,7 @@ class Template extends BaseCompiler {
if ($this->smarty->getFunctionHandler($base_tag)) {
if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($base_tag, $this)) {
return (new \Smarty\Compile\PrintExpressionCompiler())->compile(
['nofilter'], // functions are never auto-escaped
[],
$this,
['value' => $this->compileFunctionCall($base_tag, $args, $parameter)]
);
+1
View File
@@ -210,6 +210,7 @@ class Debug extends Data
$debObj->error_reporting = E_ALL & ~E_NOTICE;
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . __DIR__ . '/../debug.tpl';
$debObj->registered_resources = array();
$debObj->registered_filters = array();
$debObj->escape_html = true;
$debObj->caching = \Smarty::CACHING_OFF;
// prepare information of assigned variables
+1 -1
View File
@@ -66,7 +66,7 @@ class Math extends Base {
$equation = preg_replace('/\s+/', '', $equation);
// Adapted from https://www.php.net/manual/en/function.eval.php#107377
$number = '-?(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
$functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))';
$operators = '[,+\/*\^%-]'; // Allowed math operators
$regexp = '/^((' . $number . '|' . $functionsOrVars . '|(' . $functionsOrVars . '\s*\((?1)*\)|\((?1)*\)))(?:' . $operators . '(?1))?)+$/';
-2
View File
@@ -261,8 +261,6 @@ class Security {
* @return boolean true if tag is trusted
*/
public function isTrustedTag($tag_name, $compiler) {
$tag_name = strtolower($tag_name);
// check for internal always required tags
if (in_array($tag_name, ['assign', 'call'])) {
return true;
+8 -1
View File
@@ -53,7 +53,7 @@ class Smarty extends \Smarty\TemplateBase {
/**
* smarty version
*/
const SMARTY_VERSION = '5.0.0-rc1';
const SMARTY_VERSION = '5.0.0';
/**
* define caching modes
@@ -384,6 +384,13 @@ class Smarty extends \Smarty\TemplateBase {
*/
public $registered_classes = [];
/**
* registered filters
*
* @var array
*/
public $registered_filters = [];
/**
* registered resources
*
+1 -1
View File
@@ -196,7 +196,7 @@ class Template extends TemplateBase {
);
} else {
if ((!$this->caching || $this->getCached()->getNocacheCode() || $this->getSource()->handler->recompiled)
&& !$no_output_filter
&& !$no_output_filter && isset($this->smarty->registered_filters['output'])
) {
echo $this->smarty->runOutputFilters(ob_get_clean(), $this);
} else {
@@ -30,35 +30,4 @@ class AutoEscapeTest extends PHPUnit_Smarty
$tpl->assign('foo', '<a@b.c>');
$this->assertEquals("&lt;a@b.c&gt;", $this->smarty->fetch($tpl));
}
/**
* test 'escapeHtml' property
* @group issue906
*/
public function testAutoEscapeDoesNotEscapeFunctionPlugins()
{
$this->smarty->registerPlugin(
\Smarty\Smarty::PLUGIN_FUNCTION,
'horizontal_rule',
function ($params, $smarty) { return "<hr>"; }
);
$tpl = $this->smarty->createTemplate('eval:{horizontal_rule}');
$this->assertEquals("<hr>", $this->smarty->fetch($tpl));
}
/**
* test 'escapeHtml' property
* @group issue906
*/
public function testAutoEscapeDoesNotEscapeBlockPlugins()
{
$this->smarty->registerPlugin(
\Smarty\Smarty::PLUGIN_BLOCK,
'paragraphify',
function ($params, $content) { return $content == null ? null : "<p>".$content."</p>"; }
);
$tpl = $this->smarty->createTemplate('eval:{paragraphify}hi{/paragraphify}');
$this->assertEquals("<p>hi</p>", $this->smarty->fetch($tpl));
}
}
@@ -39,17 +39,6 @@ class RegisterFunctionTest extends PHPUnit_Smarty
$this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testfunction value=1}'));
}
/**
* test registerPlugin method for function case-sensitive
*/
public function testRegisterFunctionCaseInsensitive()
{
$this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testFunction', 'myfunction');
$this->assertEquals('myfunction',
$this->smarty->getRegisteredPlugin(Smarty::PLUGIN_FUNCTION, 'testFunction')[0]);
$this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testFunction value=1}'));
}
/**
* test registerPlugin method for function class
*/
@@ -154,7 +143,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty
public function testUnregisterFunctionNotRegistered()
{
$this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction');
$this->assertNull($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'));
$this->assertNull($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'));
}
/**
@@ -164,34 +153,8 @@ class RegisterFunctionTest extends PHPUnit_Smarty
{
$this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testfunction', 'myfunction');
$this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction');
$this->assertIsArray($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_BLOCK, 'testfunction'));
$this->assertIsArray($this->smarty->getRegisteredPlugin(Smarty::PLUGIN_BLOCK, 'testfunction'));
}
/**
* Test case (in)sensitivy of plugin functions
* @param $registerName
* @param $templateString
* @return void
* @throws \Smarty\Exception
* @group issue907
* @dataProvider dataProviderForCaseSensitivity
*/
public function testCaseSensitivity($registerName, $templateString) {
$this->smarty->registerPlugin(
Smarty::PLUGIN_FUNCTION,
$registerName,
function($params, $smarty) { return 'function-output'; });
$this->assertEquals('function-output', $this->smarty->fetch('string:' . $templateString));
}
public function dataProviderForCaseSensitivity() {
return [
['customTag', '{customTag}'],
['customtag', '{customtag}'],
];
}
}
function myfunction($params, $smarty)
@@ -93,14 +93,6 @@ class MathTest extends PHPUnit_Smarty
$this->assertEquals($expected, $this->smarty->fetch($tpl));
}
public function testNegativeNumbers()
{
$this->smarty->disableSecurity();
$expected = "-19 -- 4.1";
$tpl = $this->smarty->createTemplate('eval:{$x = 4}{$y = 5.5}{math equation="-2.0*(x+y)" x=$x y=$y} -- {math equation="-20.5 / -5"}');
$this->assertEquals($expected, $this->smarty->fetch($tpl));
}
public function testSyntaxFormat()
{
$this->smarty->disableSecurity();