aidid/ci_blade 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

aidid/ci_blade

最新稳定版本:v1

Composer 安装命令:

composer require aidid/ci_blade

包简介

Blade View for Codeigniter 3

README 文档

README

This can render .blade.php in Codeinteger and can convert Strings into blade templating system.

  • This library follows HMVC
  • This has predefine cache for rendering files quickly
  • It supports:

    comments, echos, forelse, empty, includes, layouts, section_start, section_end, section, sectionend, extends, yields, yield_sections, extensions, else, unless, endunless, endforelse, structure_openings, structure_closings

Installation

composer require aidid/ci_blade

Initialization

use \Aidid\BladeView\BladeView;
	public $bladeview;
	public function __construct() {
		parent::__construct();
		$this->bladeview = new BladeView();
	}

Methods:

$this->bladeview->set('name', 'Jhon')
				->set('car_array', array("BMW", "FORD", "Mazda"))
				->append('car_array', "Volvo")
				->set_data(array('age' => 22, 'gender' => 'male'))
				->render('test', array('message' => 'Hello World!'));

Rendaring *blade.php

$data = array(
	"foo" => "Hello",
	"bar" => "World",
);
$this->bladeview->render("test", $data);  //File extension *blade.php

Rendaring String

$string = "{{\$foo}} {{\$bar}}";
$data = array(
	"foo" => "<b>Hello</b>",
	"bar" => "World",
);
$this->bladeview->render($string, $data, false); //3rd parameter false is important

Making blade template

<div>
    @include('template-example/header')
</div>
<div>
    @yield('content')
</div>
<div>
    @include('template-example/footer')
</div>
@extends('template-example/baseview')
@section('content')
    i am the home page
@endsection

You can also save the blade output in a variable

$View_blade_output=$this->bladeview->render("test", $data,true,true);
$String_blade_output=$this->bladeview->render($string, $data,flase,true);

Example

use \Aidid\BladeView\BladeView;

class Example extends CI_Controller {
	public $bladeview;
	public function __construct() {
		parent::__construct();
		$this->bladeview = new BladeView();
	}

	public function index() {
		$this->bladeview->render('templated-view'); //check file under view folder
	}

	public function viewWithVariable() {
		$foo = "Foo";
		$bar = "Bar";
		$this->bladeview->render('view-with-variable', compact('foo', 'bar'));
	}

	public function directRender() {
		$string = "{{\$foo}} {{\$bar}}";
		$data = array(
			"foo" => "<b>Hello</b>",
			"bar" => "World",
		);
		$this->bladeview->render($string, $data, false); //3rd parameter false is important
	}
}

Check this controller for better understand of BladeView's function. Check this View Folder for better understand of view structure.

For more details please follow laravel blade documentaion.

统计信息

  • 总下载量: 325
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-04-25