PHP Classes
elePHPant
Icontem

PHP Templater: Process and render templates similar to AngularJS

Recommend this page to a friend!
  Info   View files Documentation   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-08-19 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 64 This week: 1All time: 9,498 This week: 296Up
Version License PHP version Categories
php-templater 1.0BSD License5HTML, PHP 5, Templates
Description Author

This package can process and render templates similar to AngularJS.

It can take a template string and an array with parameter values that will be used to process the template.

The package provides a base replacer interface that can be implemented by classes that define different means to find template marks with a syntax similar to AngularJS and replace the marks with values generated dynamically using context information based on the template processing parameters.

  Performance   Level  
Name: Till Wehowski <contact>
Classes: 17 packages by
Country: Germany Germany
Age: 40
All time rank: 124579 in Germany Germany
Week rank: 166 Up7 in Germany Germany Up
Innovation award
Innovation award
Nominee: 5x

 

Details

php-templater

This package can process and render templates similar to AngularJS.

Templates {{my.var}} for ['my'=>['var'=>'Hello, World']]

Examples

frdl\Templater\SimpleDotNotationReplacer

Based on regular expression.

$arr = [
    'test' => [
        'message' => 'Hello, World',
    ],

];


echo \frdl\Templater\SimpleDotNotationReplacer::replace(\frdl\Context::create($arr), 
    'Message: {{test.message}}');
    //Message: Hello, World

frdl\Templater\AdvancedReplacer

Based on https://github.com/wmde/php-vuejs-templating .

$arr = [
    'show' => false,
    'test' => [
        'message' => 'Hello, World',
    ],
    'items' => [
        [ 'property' => 'value1' ],
        [ 'property' => 'value2' ],
    ],
];


echo \frdl\Templater\AdvancedReplacer::replace(\frdl\Context::create($arr),   
  '<div>
     <h1 ng-bind="title"></h1>
     <p>Message: {{test.message}}</p>
     <p ng-show="show">this should be hidden</p>
     <p ng-if="!show">this should be visible</p>
     <p><a ng-repeat="item in items">{{item.property|ucfirst}}</a></p>
    
    </div>');
  
/*
//Renders to:  
<div>
     <h1><p>Template Test Title</p></h1>
     <p>Message: Hello, World</p>
     
     <p>this should be visible</p>
     <p><a>Value1</a><a>Value2</a></p>
    
    </div>

*/
  Files folder image Files  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imagefrdl (1 directory)

  Files folder image Files  /  src  /  frdl  
File Role Description
Files folder imageTemplater (6 files)

  Files folder image Files  /  src  /  frdl  /  Templater  
File Role Description
  Plain text file AdvancedReplacer.php Class Class source
  Plain text file Component.php Class Class source
  Plain text file Replacer.php Class Class source
  Plain text file ReplacerInterface.php Class Class source
  Plain text file SimpleDotNotationReplacer.php Class Class source
  Plain text file Templating.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:64
This week:1
All time:9,498
This week:296Up