Download the PHP package uuf6429/expression-language-tplstring without Composer
On this page you can find all versions of the php package uuf6429/expression-language-tplstring. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download uuf6429/expression-language-tplstring
More information about uuf6429/expression-language-tplstring
Files in uuf6429/expression-language-tplstring
Package expression-language-tplstring
Short Description Template String support for Symfony Expression Language
License MIT
Homepage https://github.com/uuf6429/expression-language-tplstring
Informations about the package expression-language-tplstring
🪡 Template Strings
for Symfony Expression Language (5-8)
What looks like a dot, a cross and a wave, and does the same thing?
It's the string concatenation operator, of course!
PHP uses a dot/period (
.), many languages including JavaScript use+, whereas Symfony Expression Language uses the tilde (~).
This library provides a translation layer on top of Expression Language that converts template strings in ES6 format* to a valid expression. While an updated Expression Language subclass wrapper is provided for convenience, you don't have to use it – you can use the provided trait instead.
* only ES6 string interpolation (with any expressions and nesting) is supported; f.e. tagged templates are not.
🔌 Installation
As always, the recommended and easiest way to install this library is through Composer:
🚀 Usage
If you do not plan on extending Symfony Expression Language class, you can use the provided drop-in:
Otherwise, you can also use the provided trait:
🪆 Nested Template Strings
Since the translator uses a robust state machine, you can nest template strings infinitely:
🚨 Robust Error Handling
Unmatched template boundaries (like unclosed backticks `, or unclosed${, or unclosed quotes'/") will immediately trigger aSymfony\Component\ExpressionLanguage\SyntaxError` with precise details and position: