mage-obsidian/module-modern-frontend-twig
Composer 安装命令:
composer require mage-obsidian/module-modern-frontend-twig
包简介
Optional Twig template engine for MageObsidian ModernFrontend. Installing it registers a .twig engine alongside Magento's native .phtml.
README 文档
README
Optional add-on for mage-obsidian/module-modern-frontend.
Installing this module registers a .twig template engine alongside Magento's native .phtml;
removing it leaves only .phtml. Nothing else opts in — the engine is enabled by the module's presence.
How it works
Magento dispatches a block's template by file extension
(Magento\Framework\View\Element\Template::fetchView → TemplateEnginePool). This module adds a
twig entry to that engine map, so a block whose template ends in .twig is rendered by Twig while
every .phtml keeps using the PHP engine. .twig and .phtml coexist in the same theme, and the
theme fallback resolves .twig overrides exactly like .phtml.
What you get over phtml
- HTML auto-escaping on by default — the main security gain; opt out per value with Twig's
raw. - Twig inheritance (
{% extends %}/{% block %}) and includes, resolved through the Magento theme fallback (useVendor_Module::path.twignames). - The MageObsidian bridge, so a
.twigmounts Vue islands like a.phtml:{{ render_vue('Vendor_Module::Component', { prop: value }) }}{{ child_html('alias') }},{{ hero_icon('check', 'solid', '24') }}{{ vite_url(path) }},{{ component_path(name) }},{{ view_file_url(fileId) }}- filters mirroring
$escaper:|escape_url,|escape_html_attr,|escape_js,|escape_css
- Block data via
{{ block.getX() }}/{{ block.getData('x') }}.
Compiled templates are cached under var/cache/twig. In developer mode templates auto-reload on
change and strict_variables / debug are enabled.
Note: this engine improves server-template ergonomics. It does not change runtime/browser performance — that is governed by the Vue/Vite/Tailwind output.
Documentation
For more details, visit the official documentation.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-22