PHP Classes

PHP Client Side Cache Template: Process template that can be cached on the browser

Recommend this page to a friend!
  Info   View files Documentation   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 97 This week: 1All time: 9,825 This week: 560Up
Version License PHP version Categories
kolserdav-templater 1.0.0MIT/X Consortium ...7.1HTML, Cache, Templates, PHP 7
Description 

Author

This package can process template that can be cached on the browser.

It processes a given template file with placeholder positions by having those positions replaced by template variables.

The package generates HTML with some JavaScript and a manifest file to hint the browsers to cache the served pages on the browser side when the user is off-line and is not able to access the site.

The generated pages show at the bottom a list of pages that can be browsed using the browser side cache.

Picture of Sergey Kol'miller
  Performance   Level  
Name: Sergey Kol'miller <contact>
Classes: 5 packages by
Country: Russian Federation Russian Federation
Age: 40
All time rank: 354698 in Russian Federation Russian Federation
Week rank: 416 Up24 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 3x

Documentation

Simple template engine This component has the ability to cache on the client side, with the availability of visited pages in offline.

_Installation_

~$ composer require kolserdav/templater

_Dependencies_

"php" : "^7.0" "kolserdav/router": "^0.2.0" --dev "phpunit" : "^7.0"

_package.json_ ` "dependencies": {

 "ajaxsim": "^1.0.0",
 "dist-cookie": "^0.0.7"

}, "devDependencies": {

 "webpack": "^4.5.0"`
 

Component templater use kolserdav/router module, and working project must be used single point access. For module kolserdav/router settings can be read on: https://github.com/kolserdav/router.

_Using in template_

At the moment the following structures are supported

{{ variable }}  //some variable need sent to render(['variable' => 'value'],[])
 
{% field %}  //HTML block field, need sent to render([],['field' => 'path/patch.file.html'])

{% for value in array %}{{ value }}{% endfor %} //for in, need sent to render(['for_array' => [1,2,3])  

To enable syntax highlighting in your IDE, you can use the .twig extension.

Construction for in supported using with tags. For example:

{% for value in array %}<h3>{{ value }}</h3><br>{% endfor %}

Bud for correct work name 'value' must be unique for one page. And it is written in one line. For example

{% for value1 in array_one %}{{ value1 }}{% endfor %}

{% for value2 in array_two %}{{ value2 }}{% endfor %}

_Using_

For use this module need some dependencies write in your index file or controller file...

Optional (if you need the cache of pages)

use Avir\Templater\Module\Config;

$config = new Config();
$config->setConfig([
    'cache' => '/path/cache/catalog/+{pages}' //default : false  {pages} - auto create catalog
    'userCache' => '/path/usrCache/catalog/+{users}' //default : false {users} - auto create catalog
]);

Require (to include template)

use Avir\Templater\Module\Render;

$obj = new Render('/path/template/catalog', '/template.file'); 
$obj->render(
    [
        'first_variabe' => 'string', //{{ key }} 
        'second_variable' => 111,
        'for_array1' => [1,2,3,4], //arrays need have 'for_' before
        'for_array2' => [4,3,2,1]
    ],
    [
        'field1' => 'patch.file', //patches repository /template-catalog/views
        'field2' => 'path/patch.file' //patches repository /template-catalog/views/path
        ]);

It works.


  Files folder image Files  
File Role Description
Files folder imagesrc (1 directory)
Files folder imagestorage (3 files)
Files folder imagetests (1 directory)
Plain text file composer.json Data Auxiliary data
Plain text file package.json Data Auxiliary data
Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageModule (6 files, 1 directory)

  Files folder image Files  /  src  /  Module  
File Role Description
Files folder imageAjax (1 file)
  Plain text file Background.php Class Class source
  Plain text file CacheHandler.php Class Class source
  Plain text file Config.php Class Class source
  Plain text file Helper.php Class Class source
  Plain text file Render.php Class Class source
  Plain text file Templater.php Class Class source

  Files folder image Files  /  src  /  Module  /  Ajax  
File Role Description
  Plain text file AjaxHelper.php Class Class source

  Files folder image Files  /  storage  
File Role Description
  Plain text file .manifest.appcache Data Auxiliary data
  Plain text file card.json Data Auxiliary data
  Plain text file templater.js Data Auxiliary data

  Files folder image Files  /  tests  
File Role Description
Files folder imagetemplatertest (1 file)

  Files folder image Files  /  tests  /  templatertest  
File Role Description
  Plain text file Test.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:97
This week:1
All time:9,825
This week:560Up