2017 © Pedro Peláez
 

library light-html-template

Bixev light HTML template system

image

bixev/light-html-template

Bixev light HTML template system

  • Saturday, October 21, 2017
  • by thomas.leviandier@gmail.com
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3,180 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 11 % Grown

The README.md

A simple html templating system with HTML-only templates, and only a few php commands., (*1)

It is scripting language agnostic and display language agnostic. You will have to know only 3 structure :, (*2)

  • block : used to display none, one or many times a piece of code
  • var : used to display a value (optionnaly filtered)
  • import : used to import template from another file

Installation

It's recommended that you use Composer to install this lib., (*3)

composer require bixev/light-html-template "~1.0"

This will install this library and all required dependencies., (*4)

so each of your php scripts need to require composer autoload file, (*5)

<?php

require 'vendor/autoload.php';

Usage

HTML template

Your .html templates (or string) can only contain HTML and <bloc> / {var} to work., (*6)

Your php views will deal with conditions, loops and more, (*7)

HTML content (into a .html template file, or into a string var from php) :, (*8)

Before first bloc {{var1 | unknownFunction}}
{{ unknownVar }}{{unknownVar | unknownFunction}}
{{bloc:myFirstBloc}}

    first bloc start {{var1}}

    {{bloc:mySecondBloc}}
        content of second bloc with {{var}}
        {{bloc:my5thBloc}}
            content of 5th bloc with {{ var }}
        {{endbloc:my5thBloc}}
    {{endbloc:mySecondBloc}}

    first bloc middle {{var3 }}

    {{ bloc:myThirdBloc }}
        content of third bloc with {{var}}
    {{endbloc:myThirdBloc}}

    {{bloc:my4thBloc}}
        content of 4th bloc with {{var}}
    {{ endbloc:my4thBloc }}

    first bloc end {{ var3}}

{{endbloc:myFirstBloc}}
After first bloc {{var1}}

php content (your php view) :, (*9)

<?php
$tpl = \Bixev\LightHtmlTemplate\Factory::newTemplateFromString($template);
$tpl->pB(
    [
        'var1'        => 'testVal1',
        'myFirstBloc' => [
            'var1'         => 'testFirst1',
            'var2'         => 'testFirst2',
            'var3'         => 'testFirst3',
            'mySecondBloc' => [
                'var'       => 'testSecond',
                'my5thBloc' => [
                    ['var' => 'test4th',],
                    ['var' => 'test5th',],
                ],
            ],
            'myThirdBloc'  => [
                ['var' => 'testThird1',],
                ['var' => 'testThird2',],
            ],
        ],
    ]
);
$result = $tpl->render();

echo $result;

This will result in, (*10)

Before first bloc testVal1



    first bloc start testFirst1


        content of second bloc with testSecond

            content of 5th bloc with test4th

            content of 5th bloc with test5th



    first bloc middle testFirst3


        content of third bloc with testThird1

        content of third bloc with testThird2




    first bloc end testFirst3


After first bloc testVal1

Test

vendor/bin/phpunit --bootstrap vendor/autoload.php ./test/BixevTest/LightHtmlTemplateTest/TplTest.php

The Versions

21/10 2017

dev-master

9999999-dev

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

21/10 2017

2.0.9

2.0.9.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

24/10 2016

2.0.7

2.0.7.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

24/10 2016

2.0.8

2.0.8.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

19/09 2016

2.0.6

2.0.6.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

13/09 2016

2.0.5

2.0.5.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

08/09 2016

2.0.4

2.0.4.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

25/08 2016

2.0.3

2.0.3.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

24/08 2016

2.0.2

2.0.2.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

20/07 2016

2.0.1

2.0.1.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

06/07 2016

2.0.0

2.0.0.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires

 

06/03 2016

1.0.1

1.0.1.0

Bixev light HTML template system

  Sources   Download

MIT

The Requires