定制 mage-obsidian/module-modern-frontend-twig 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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::fetchViewTemplateEnginePool). 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 (use Vendor_Module::path.twig names).
  • The MageObsidian bridge, so a .twig mounts 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
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-22