Derste birlikte hazırladığımız PHP Tema Motoru kaynak kodları

Overview

Prototürk Template Engine

Prototürk'de sorulan bir soru üzerine videoda birlikte hazırladığımız php ile geliştirilmiş basit bir tema motoru.

Geçerli direktifler

  • @if, @elseif ve @else
  • @empty ve @endempty
  • @isset ve @endisset
  • @foreach ve @endforeach
  • @forelse, @empty ve @endforelse
  • @php ve @endphp
  • @json
  • @dump ve @dd
  • @include
  • @extends, @yield ve @section

Kullanımı

<?php

require __DIR__ . '/PtEngine.php';

$pt = new PtEngine([
    'views' => __DIR__ . '/views',
    'cache' => __DIR__ . '/cache',
    'suffix' => 'blade'
]);

echo $pt->view('index', [
    'name' => 'Tayfun',
    'title' => 'Prototurk.com',
    'todos' => [
        'todo1',
        'todo2',
        'todo3',
        'todo4'
    ]
]); // views/index.blade.php dosyasını çağırır

Ayrıca özel direktiflerde tanımlayabilirsiniz, örneğin;

$pt->directive('style', function($href = null) {
    if ($href) {
        return '<link rel="stylesheet" type="text/css" href="' . $href . '" />';
    }
    return '<style>';
});

$pt->directive('endstyle', function() {
    return '</style>';
});

$pt->directive('page', function($page) {
    return '<?php if (isset($_GET["page"]) && $_GET["page"] === \'' . $page . '\'): ?>';
});

$pt->directive('endpage', function() {
    return '<?php endif; ?>';
});

Daha fazla örnek kullanım için views/ klasörüne gözatın.

You might also like...
Provides TemplateView and TwoStepView using PHP as the templating language, with support for partials, sections, and helpers.

Aura View This package provides an implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating language. It support

A complete and fully-functional implementation of the Jade template language for PHP

Tale Jade for PHP Finally a fully-functional, complete and clean port of the Jade language to PHP — Abraham Lincoln The Tale Jade Template Engine brin

TextGenerator is a PHP package that aims to generate automated texts from data.

TextGenerator TextGenerator is a PHP package that aims to generate automated texts from data. Feel free to comment and contribute. Features Text gener

A faster, safer templating library for PHP
A faster, safer templating library for PHP

Brainy Brainy is a replacement for the popular Smarty templating language. It is a fork from the Smarty 3 trunk. Brainy is still very new and it's lik

A ready-to-use Model View Controller template in PHP

PHP-MVC-Template A ready-to-use Model View Controller template in PHP Use this repo as a template! (Or clone it) Start to configure your MVC file Afte

Provides a GitHub repository template for a PHP package, using GitHub actions.

php-package-template Installation 💡 This is a great place for showing how to install the package, see below: Run $ composer require ergebnis/php-pack

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!
The free-to-use template for your Imagehost-website made with PHP, HTML and CSS!

The free-to-use template for your Imagehost-website made with PHP, HTML and CSS! Some information before we start This repo is only code related, to a

Qiq templates for PHP 8.

Qiq Templates for PHP 8 This package provides a PHP 8.0 implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating

Standalone Skeltch templating engine for PHP

SkeltchGo is a standalone version of Glowie Skeltch templating engine for PHP, intented to use from outside the framework.

Comments
  • İf condition parse error

    İf condition parse error

    ` @if(count([]) > 0) test elseif(count([]) > 0) @else test else @endif

    @if(!count($myArray) > 0) test @else test else @endif `

    Match result from ($2) => count([] !count($myArray

    opened by debiyach 0
Owner
Tayfun Erbilen
It's all about dreams
Tayfun Erbilen
A PHP project template with PHP 8.1, Laminas Framework and Doctrine

A PHP project template with PHP 8.1, Laminas Framework and Doctrine

Henrik Thesing 3 Mar 8, 2022
Twig, the flexible, fast, and secure template language for PHP

Twig, the flexible, fast, and secure template language for PHP Twig is a template language for PHP, released under the new BSD license (code and docum

Twig 7.7k Jan 1, 2023
A Mustache implementation in PHP.

Mustache.php A Mustache implementation in PHP. Usage A quick example: <?php $m = new Mustache_Engine(array('entity_flags' => ENT_QUOTES)); echo $m->re

Justin Hileman 3.2k Dec 24, 2022
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.

Smarty 3 template engine smarty.net Documentation For documentation see www.smarty.net/docs/en/ Requirements Smarty can be run with PHP 5.2 to PHP 7.4

Smarty PHP Template Engine 2.1k Jan 1, 2023
Native PHP template system

Plates Plates is a native PHP template system that's fast, easy to use and easy to extend. It's inspired by the excellent Twig template engine and str

The League of Extraordinary Packages 1.3k Jan 7, 2023
☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites.

Latte: amazing template engine for PHP Introduction Latte is a template engine for PHP which eases your work and ensures the output is protected again

Nette Foundation 898 Dec 25, 2022
Multi target HAML (HAML for PHP, Twig, )

Multi target HAML MtHaml is a PHP implementation of the HAML language which can target multiple languages. Currently supported targets are PHP and Twi

Arnaud Le Blanc 363 Nov 21, 2022
PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages

PHPTAL - Template Attribute Language for PHP Requirements If you want to use the builtin internationalisation system (I18N), the php-gettext extension

PHPTAL 175 Dec 13, 2022
View template engine of PHP extracted from Laravel

Blade 【简体中文】 This is a view templating engine which is extracted from Laravel. It's independent without relying on Laravel's Container or any others.

刘小乐 143 Dec 13, 2022
PHP 5.3 Mustache implementation

Phly\Mustache MOVED! This package has moved to phly/phly-mustache, and the package name has changed to phly/phly-mustache. I have updated packagist to

phly 123 Jan 11, 2022