tda-hienmv / parser
FuelPHP 1.x 解析器包
1.8.2
2019-06-27 14:57 UTC
Requires
- composer/installers: ~1.0
This package is auto-updated.
Last update: 2024-09-12 13:38:22 UTC
README
安装
简单地将 parser
添加到您的 config.php 中 always_loaded.packages
配置选项。
包含的解析器
- Markdown - Michel Fortin 的 PHP 版本 Markdown。
用法
// old usage still valid, will load app/views/example.php View::forge('example'); // load a Mustache template, will load and parse app/views/example.mustache View::forge('example.mustache'); // load a Twig template, will load and parse app/views/example.twig View::forge('example.twig'); // load a Hybrid Haml / Twig template, ATTENTION: this one expects app/views/example.twig and {% haml %} code at the top of the view View::forge('example.mthaml'); // load a Jade template, will load and parse app/views/example.jade View::forge('example.jade'); // load a Haml template, will load and parse app/views/example.haml View::forge('example.haml'); // load a Smarty template, will load and parse app/views/example.smarty View::forge('example.smarty'); // load a Lex template, will load and parse app/views/example.lex View::forge('example.lex'); // load a Dwoo template, ATTENTION: this one expects app/views/example.tpl View::forge('example.dwoo'); // load a Handlebars template, will load and parse app/views/example.handlebars View::forge('example.handlebars');
安装解析器
为了使用支持的解析器之一,您需要通过 composer 安装它们。简单地将库添加到项目的 composer.json
文件中,然后运行 php composer.phar install
{ "require": { "dwoo/dwoo" : "*", "mustache/mustache" : "*", "smarty/smarty" : "*", "twig/twig" : "2.*", "mthaml/mthaml": "*", "pyrocms/lex": "*", "zordius/lightncandy" : "dev-master" } }
请注意,Markdown 解析器默认安装,因为它也用于 FuelPHP 核心类 Markdown
。
无法通过 composer 安装的库预期安装在 APPPATH/vendor/lib_name
中(lib_name 需要大写),您需要自己下载它们。不要更改大小写或任何内容,尽量在 vendor/lib_name
目录中保持尽可能原始,以保持更新容易(也因为是它们中的一些带有自己的自动加载器)。
您可以通过复制解析器配置文件到您的应用程序并对其进行编辑来配置它们从其他位置加载。
配置和运行时配置
目前,驱动程序仍然缺少许多它们应该接受的配置选项。它们目前都配置为与它们的解析器库的一个实例一起工作,该实例可用于配置
// Clear the cache for a specific Smarty template $view = View::forge('example.smarty'); $view->parser()->clearCache('example.smarty'); // Example static usage View_Smarty::parser()->clearCache('example.smarty');