PHPackages                             vitodtagliente/pure-template - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. vitodtagliente/pure-template

ActiveLibrary[Templating &amp; Views](/categories/templating)

vitodtagliente/pure-template
============================

The Pure Template Component

043PHP

Since Apr 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/vitodtagliente/pure-template)[ Packagist](https://packagist.org/packages/vitodtagliente/pure-template)[ RSS](/packages/vitodtagliente-pure-template/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Pure Template Component
=======================

[](#pure-template-component)

Simple and fast template engine

How To render a view
====================

[](#how-to-render-a-view)

1. Define the default path in which the engine will search for view files:

    ```
    Pure\Template\View::namespace( $default_path );
    ```
2. Instantiate a view object:

    ```
    $view = new Pure\Template\View();
    // or
    $view = new Pure\Template\View(
        array('param1' => 'value1', ... , 'paramN' => 'valueN')
    );
    ```
3. Set params:

    ```
    $view->paramJ = 'valueJ';
    ```

    In this way it is possibile to define other parameters outside the default constructor.
4. Clear params:

    ```
    $view->clear();
    ```
5. Render the output:

    ```
    $view->render(
        $filename,              // the file palced inside the base path
        $direct_output = true,   // if true, the output is displayed
        $dont_compute = false    // if true, no engine extensions are applied
    );
    ```
6. Instead of instantiate the view object, it is possibile to directly output a view by a static function:

    ```
    Pure\Template\View::make(
        $filename,
        $params = array(),
        $direct_output = true,
        $dont_compute = false
    );
    ```
7. How to locate views in different paths and render them using namespaces

    It is possible to define several namespaces, each namespace refers to a certain path

    ```
    Pure\Template\View::namespace('path/views');                // define the base namespace
    Pure\Template\View::namespace('path/views/auth', 'auth');    // define the auth namespace
    ```

    Once the namespaces are defined, it is possible to load views using the syntax

    ```
    "namespace::view_filename"
    ```

    For example:

    ```
    Pure\Template\View::make('welcome.php');        // file: path/views/welcome.php
    Pure\Template\View::make('auth::login.php');    // file: path/views/auth/login.php
    ```

##### Simple example

[](#simple-example)

1. Define a view in path: views/example.php ```

        Example

    ```
2. Render the view: ```
    use Pure\Template\View;

    // Set the default path
    View::namespace('views');

    $view = new View();
    $view->foo = "Hello View!"; // set the param foo
    $result = $view->render('example.php');
    ```
3. The output will be this: ```

        Example

        Hello View!

    ```

How To avoid inline calls
=========================

[](#how-to-avoid--inline-calls)

In the last example we used

```

```

to render the foo variable, which is defined as:

```
$view = new View();
$view->foo = "Hello View!"; // set the param foo
```

If during the render phase, the argument $dont\_compute is set to false, the view engine extensions are called. Which means that more features are available.

1. Render paramas in fast way: ```

        {{ $foo }}

    ```

How To extend views
===================

[](#how-to-extend-views)

Another Pure Template extension let to extend views and override contents.

1. To extend a view: ```
    @extends('view_filename')
    ```

    the @extends must be the first statement
2. Sections have to be defined in parent view: ```
    @section('section_name')
    ```
3. Sections can be override as follow: ```
    @begin('section_name')
     HTML content
    @end
    ```

##### Practical example

[](#practical-example)

1. Define a parent template placed in views/template.php ```

        Example

        @section('content')

    ```
2. Define a new view derived by this template: ```
    @extends('template.php')

    @begin('content')
    Hello View!
    @end
    ```
3. The output will be this: ```

        Example

        Hello View

    ```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/61137c8fad7251ed9bcd84692d5ef8153dc8de8c6a09d182b9a1d69854d2a0b2?d=identicon)[vitodtagliente](/maintainers/vitodtagliente)

---

Top Contributors

[![vitodtagliente](https://avatars.githubusercontent.com/u/5153783?v=4)](https://github.com/vitodtagliente "vitodtagliente (10 commits)")

### Embed Badge

![Health badge](/badges/vitodtagliente-pure-template/health.svg)

```
[![Health](https://phpackages.com/badges/vitodtagliente-pure-template/health.svg)](https://phpackages.com/packages/vitodtagliente-pure-template)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
