feldsam-inc / fuel-parser
FuelPHP 1.x 解析器包
1.9-BETA1
2018-05-03 08:58 UTC
Requires
- composer/installers: ~1.0
This package is not auto-updated.
Last update: 2024-09-30 01:49:38 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');