fuel / 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-08-30 01:07:58 UTC
README
安装
只需将 parser
添加到您的 config.php 中 always_loaded.packages
配置选项。
包含的解析器
- Markdown - Michel Fortin 编写的 Markdown 的 PHP 版本。
使用方法
// 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 actually loads 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 Plates template, will load and parse app/views/example.plates View::forge('example.plates'); // 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 actually loads app/views/example.tpl View::forge('example.dwoo'); // load a Handlebars template, will load and parse app/views/example.handlebars View::forge('example.handlebars'); // load a Plates template, ATTENTION: this one actually loads app/views/example.tpl View::forge('example.plates');
安装解析器
为了使用支持的解析器之一,您需要通过 composer 安装它们。只需将库添加到项目的 composer.json
,然后运行 php composer.phar install
{ "require": { "dwoo/dwoo" : "*", "mustache/mustache" : "*", "smarty/smarty" : "*", "twig/twig" : "2.*", "mthaml/mthaml": "*", "pyrocms/lex": "*", "league/plates" : "3.*", "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');