Download the PHP package magehx/mage-template-utils without Composer
On this page you can find all versions of the php package magehx/mage-template-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download magehx/mage-template-utils
More information about magehx/mage-template-utils
Files in magehx/mage-template-utils
Package mage-template-utils
Short Description Magento 2 module that provides powerful global utility features to the templates.
License MIT
Informations about the package mage-template-utils
MageHx_MageTemplateUtils
A Magento 2 module that introduces convenient global utilities for use in .phtml templates, helping you write cleaner, more expressive code.
β¨ Features
π Escaper Shortcuts
Use simple closure aliases instead of long $escaper method calls:
| Alias | Equivalent |
|---|---|
$esc->html() |
$escaper->escapeHtml() |
$esc->js() |
$escaper->escapeJs() |
$esc->url() |
$escaper->escapeUrl() |
$esc->htmlAttr() |
$escaper->escapeHtmlAttr() |
Example:
`
Instead of:
π¦ ViewModel Provider β $viewModelProvider
Fetch a ViewModel instance directly inside a .phtml file without having to declare it in layout XML:
π§Ύ Form Key Helper β $formKey
Insert a hidden form key input in one line:
Simple, secure, and saves time.
π CSP Nonce Provider β $nonce
Generate a valid CSP nonce for inline scripts:
Essential for security-conscious development.
π¨ Conditional Class Names β $classNames
Apply dynamic class names with ease and clarity:
Before:
After:
Improves readability and maintainability of conditional UI.
π¦ Installation
π Requirements
- PHP 8.1+
π οΈ License
MIT β free to use and modify.
π¬ Feedback / Contributions
PRs and issues are welcome. Letβs make Magento templating less painful!