2017 © Pedro Peláez
 

library dirk

PHP template system

image

artoodetoo/dirk

PHP template system

  • Tuesday, January 10, 2017
  • by artoodetoo
  • Repository
  • 2 Watchers
  • 3 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Dirk PHP Templates

Tiny and powerfull template engine with syntax almost the same as in laravel/blade., (*1)

Installation

The package can be installed via Composer by requiring the "artoodetoo/dirk" package in your project's composer.json., (*2)

{
    "require": {
        "artoodetoo/dirk": "dev-master"
    }
}

Usage

/views/hello.dirk.html, (*3)

@extends('layout/main')



<

h1>Hello {{{ $name }}}!

<

h1>

{{ $timestamp or 'Timestamp not defined' }}

@section('sidebar')

  @foreach($list as $l)


{{ $l }} @if($l == 3) is equal 3 ! @endif, (*4)

@endforeach @endsection

/views/layout/main.dirk.html, (*5)

<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>

<sidebar>

@yield('sidebar', 'Default sidebar text')

</sidebar>

@yield('content')

</body>
</html>

/web/index.php, (*6)

<?php

require 'vendor/autoload.php';

use R2\Templating\Dirk;

$view = new Dirk([
    'views' => __DIR__.'/views',
    'cache' => __DIR__.'/cache'
]);

$name = '<artoodetoo>';
$list = [1, 2, 3, 4, 5];

$view->render('hello', compact('name', 'list'));

Feature list

Echoes and comments * {{ $var }} - Echo. NOTE: it's escaped by default, like in Laravel 5! * {!! $var !!} - Raw echo without escaping * {{ $var or 'default' }} - Echo content with a default value * {{{ $var }}} - Echo escaped content * {{-- Comment --}} - A comment (in code, not in output), (*7)

Conditionals * @if(condition) - Starts an if block * @else * @elseif(condition) * @endif * @unless(condition) - Starts an unless block * @endunless, (*8)

Loops * @foreach($list as $key => $val) - Starts a foreach block * @endforeach * @forelse($list as $key => $val) - Starts a foreach with empty block * @empty * @endforelse * @for($i = 0; $i < 10; $i++) - Starts a for block * @endfor * @while(condition) - Starts a while block * @endwhile, (*9)

Inheritance and sections * @include(file) - Includes another template * @extends('layout') - Extends a template with a layout * @section('name') - Starts a section * @endsection - Ends section * @yield('section') - Yields content of a section. * @show - Ends section and yields its content * @stop - Ends section * @append - Ends section and appends it to existing of section of same name * @overwrite - Ends section, overwriting previous section of same name, (*10)

License

The Dirk is open-source software, licensed under the MIT license, (*11)

The Versions

10/01 2017

dev-master

9999999-dev

PHP template system

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar artoodetoo

templating package templates views dirk

16/05 2016

v1.0.1

1.0.1.0

PHP template system

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar artoodetoo

templating package templates views dirk

25/02 2015

1.0.0

1.0.0.0

PHP template system

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar artoodetoo

templating package templates views dirk