简体   繁体   English

刀片模板引擎可以与codeigniter一起使用吗?

[英]The blade template engine can be used with codeigniter?

The template engine called blade can be used with codeigniter or pure php? 名为blade的模板引擎可以与codeigniter或纯php一起使用吗? I know that it can be used with laravel and I'd like to know if also can be used with any other php framework or with pure php 我知道它可以与laravel一起使用,我想知道是否也可以与任何其他PHP框架或纯PHP一起使用

Blade can be used stand-alone in PHP. Blade可以在PHP中独立使用。

This means you can comfortably use it in CodeIgniter. 这意味着您可以在CodeIgniter中轻松使用它。

https://github.com/PhiloNL/Laravel-Blade https://github.com/PhiloNL/Laravel-Blade

Then again, you will need composer for that. 然后,你需要composer

Alternatively you could use this CodeIgniter Library to simulate Blade: CodeIgniter Slice-Libray 或者,您可以使用此CodeIgniter库来模拟Blade: CodeIgniter Slice-Libray

It works pretty like Blade and it was designed directly for CodeIgniter! 它非常像Blade,它直接为CodeIgniter设计!

For the record and as answer to another post: 为了记录和作为另一篇文章的答案:

I tested many libraries to run blade outside Laravel (that i don't use) and most (with all respect of the coders) are poor hacks of the original library that simply copied and pasted the code and removed some dependencies yet it retains a lot of dependencies of Laravel . 我测试了许多库在Laravel之外运行刀片(我不使用),而且大多数(编码器的所有方面)都是原始库的糟糕黑客,只是复制并粘贴代码并删除了一些依赖关系但它保留了很多Laravel的依赖关系

I created an alternative for blade that its free (MIT license, ie close source/private code is OK) in a single file and without a single dependency of an external library . 我创建了一个刀片替代品,它在一个文件中免费(MIT许可证,即关闭源/私有代码就可以), 并且没有外部库的单一依赖关系 You could download the class and start using it, or you could install via composes (composer require eftec/bladeone). 您可以下载该类并开始使用它,或者您可以通过composes安装(composer需要eftec / bladeone)。 So even composer is optional. 所以即使是作曲家也是可选的。

https://github.com/EFTEC/BladeOne https://github.com/EFTEC/BladeOne

https://packagist.org/packages/eftec/bladeone https://packagist.org/packages/eftec/bladeone

Its 100% compatible sans the Laravel's own features (extensions). 它100%兼容没有Laravel自己的功能(扩展)。

I have done a full write up here: http://mstd.eu/index.php/2017/03/02/using-the-laravel-blade-templating-engine-in-codeigniter-3/ 我在这里写了一篇完整的文章: http//mstd.eu/index.php/2017/03/02/using-the-laravel-blade-templating-engine-in-codeigniter-3/

Basically, include the package with composer (you need to set CI up to use composer), then create a blade instance passing it your view and cache folder like so: 基本上,包括带有composer的包(您需要将CI设置为使用composer),然后创建一个刀片实例,将其传递给您的视图和缓存文件夹,如下所示:

$blade = new BladeInstance(__DIR__ . "/../views", __DIR__ . "/../cache/views");

echo $blade->render("index");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM