Git Product home page Git Product logo

blade's Introduction

Blade template standalone

This is a standalone blade template engine for PHP. It is a simple and easy to use template engine that is designed to be used in any PHP project.

Installation

You can install this package via composer using this command:

composer require binjuhor/blade

Usage

use Binjuhor\Blade\BladeTemplate;

$template = new BladeTemplate([
    'views' => 'path/to/views/folder',
    'cache' => 'path/to/cache/folder',
    'compileDir' => 'path/to/compiled/folder',
    'url' => 'http://your-app-url.test'
]);

echo $template->render('view', ['data' => 'value']);

Read more about the blade template engine here.

To compile blade templates

You can use the compile method to compile blade templates. For example, if you have a blade template called home.blade.php and you want to compile it, you can do so by calling the compile method.

$template->compile();

Example

require_once "vendor/autoload.php";

use Binjuhor\Blade\BladeTemplate as Blade;

$compileDir = __DIR__ . '/compiles';
$viewDirectory = __DIR__ . '/resources/views';
$cacheDirectory = __DIR__ . '/cache';

$page = isset($_REQUEST['f']) ? $_REQUEST['f'] : 'index';

$blade = new Blade([
	'view' => $viewDirectory,
	'cache' => $cacheDirectory,
	'compileDir' => $compileDir,
	'url' => 'http://html-generator.test'
]);

echo $blade->render($page);
$blade->compiles();

Sample project directory structure

./index.php
./cache
./compiles
./resources
    /assets
        /css
        /js
        /images
    /views
        about.blade.php
        contact.blade.php
        home.blade.php
        404.blade.php
        /partials
            header.blade.php
            footer.blade.php
            sidebar.blade.php

Check out the example directory for a complete example.

License

The MIT License (MIT). Please see License File for more information.

Credits

  • Blade template engine by Taylor Otwell
  • This package is created by Binjuhor

blade's People

Contributors

binjuhor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.