2017 © Pedro Peláez
 

library olov

Olov is a micro templating engine for PHP.

image

olov/olov

Olov is a micro templating engine for PHP.

  • Friday, March 17, 2017
  • by gboyega
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Olov is a micro templating engine for PHP

Olov uses native PHP templates but with a single elegant function o() to help you do amazing things with very simple syntax., (*1)

1. Defining blocks...

Blocks are defined like this: <?php o('+blockname') ?> with a matching close like this <?php o('-blockname') ?>., (*2)

Example of block definitions:, (*3)


<!DOCTYPE html>
<html>
<head><title>Welcome to Olov!</title></head>
<body>


Default Header Content

The default content goes here and can be replaced in a child template that extends this one. , (*4)

</body> </html>

2. Extending a base template...

To extend another template, at the very top, do: <?php o('::base.html.php') ?> See example of block definitions below., (*5)








Pimp My Header

To override the default +content block, create one in the child template and put whatever youu like in the new block! , (*6)


<small>&copy; 2020 <i>Hmm, upgrades.</i></small>

3. Template partials...

To include a template partial, do: <?php o(':partial.html.php') ?> See example of partial include below (note the difference between the syntax for ::exending and :including), (*7)












Content body here., (*8)


4. Template variables...

You can define your template variables in an associative array[] like this:, (*9)

 [
        'title' => 'Olov Template Engine for PHP', 
        'body'  =>  'Values are automatically escaped when used the template.', 
        'tags'  => [
            'php', 'template engine', 'olov'
        ]
    ];
```

**Then create Olov engine instance and render:**
```php
// Our templates folder...
$templates_path = "./my/templates/folder/":

// New instance of Olov 
$o = Olov::o($templates_path);

// Render...
$o->render('hello.html.php', $vars);

?>


Our template: ./hello.html.php, (*10)








= o('page.title') ?>

= o('page.body') ?> , (*11)

Character count: = o('page.body|length') ?>, (*12)


<small>&copy; 2020 <i>Hmm, upgrades.</i></small>

5. Loops

You can automatically print array values by doing:, (*13)

<ul>
<?php o('page.tags|each'); ?>
</ul>

This will output:, (*14)

  • php
  • template engine
  • olov

Olov wraps your array values with the <li> by default and auto escapes the text values. Olov can also wrap your loop items in multiple concentric layers of tags. For eaxample:, (*15)

<?php o('page.tags|each:b,a,li'); ?>

Outputs:, (*16)

<li><a><b>Text Value</b></a></li>

To set tag properties and attributes, define your list in your $vars array like this:, (*17)

$vars = [
    // ....
    'users' => [
        ['Jamie Foxx', 'a:href'=>'https://en.wikipedia.org/wiki/Jamie_Foxx', 'li:class'=>'name'],   
        ['Marlon Brando', 'a:href'=>'https://en.wikipedia.org/wiki/Marlon_Brando', 'li:class'=>'name'],   
        ['Thandie Newton', 'a:href'=>'https://en.wikipedia.org/wiki/Thandie_Newton', 'li:class'=>'name']
    ]
];

Then..., (*18)

<ul class="hollywood-actors">
<?php o('page.users|each:a,li'); ?>
</ul>

Throw in the blender and ..., (*19)

<ul class="hollywood-actors">
<li class="name"><a href="https://en.wikipedia.org/wiki/Jamie_Foxx">Jamie Foxx</a></li>
<li class="name"><a href="https://en.wikipedia.org/wiki/Marlon_Brando">Marlon Brando</a></li>
<li class="name"><a href="https://en.wikipedia.org/wiki/Thandie_Newton">Thandie Newton</a></li>
</ul>

6. Installation

You can require with Composer:, (*20)

$ composer require "olov/olov:~1.0"

Or clone this repo with:, (*21)

$ git clone https://github.com/olovphp/Olov.git

Or download the zip folder., (*22)


This is a quickstart guide not a real documentation (that is on the way.) In the meantime please clone the repo and run examples/index.php to see a live example. I hope you find this useful in your projects and bug reports are most welcome!, (*23)

The Versions

17/03 2017

1.x-dev

1.9999999.9999999.9999999-dev http://olovphp.github.io/Olov

Olov is a micro templating engine for PHP.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Gboyega Dada

templating php templates

17/03 2017

dev-feature-x

dev-feature-x http://olovphp.github.io/Olov

Olov is a micro templating engine for PHP.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Gboyega Dada

templating php templates

07/05 2016

1.1.1

1.1.1.0 http://olovphp.github.io/Olov

Olov is a micro templating engine for PHP.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Gboyega Dada

templating php templates

06/05 2016

1.1.0

1.1.0.0 http://olovphp.github.io/Olov

Olov is a micro templating engine for PHP.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Gboyega Dada

templating php templates

04/05 2016

1.0.0

1.0.0.0 http://olovphp.github.io/Olov

Olov is a micro templating engine for PHP.

  Sources   Download

GPL-3.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Gboyega Dada

templating php templates