PHPackages                             kocsismate90/templater - 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. kocsismate90/templater

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

kocsismate90/templater
======================

Templater

0.5.0(12y ago)116MITPHPPHP &gt;=5.3.0

Since Jun 25Pushed 7y agoCompare

[ Source](https://github.com/kocsismate90/templater)[ Packagist](https://packagist.org/packages/kocsismate90/templater)[ RSS](/packages/kocsismate90-templater/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Templater
=========

[](#templater)

I developed this library for a project where I had to replace the legacy PHP templates to Twig templates. The job was enormous: we had more than 16,000 PHP tags (sometimes with dozens of lines) in 400+ files.

So thanks to Templater I managed to successfully convert (almost barely) with automatic techniques, the 92% of the different tags, and the 85% of all the tags (the majority of the difference comes from the fact that block endings, like "}" cannot be converted without extra work).

So only ~2200 tags remained for manual conversion, but it came evident soon, that it's still too slow for me. Then I introduced "partial conversion", which means that a log file stores those tags which couldn't be fully converted, but some parts of them. It's very safe and useful for long, multiline tags: your templates are not threatened with partially working tags but you can copy the most parts of them to your template file.

Suggested working method:
-------------------------

[](#suggested-working-method)

Copy your original templates from your project's template directory to a safe location (e.g. name the folder as "my-converted-templates"). Then make another backup of it (e.g.: name it as "my-original-templates"). Now you can use Templater to modify your files in the "my-converted-templates" directory. Finally start "merging" your new templates with the original ones in your project. Remember to check for partial conversions! If you have to re-convert the tags, you can replace "my-converted-templates" with "my-original-templates".

The advantage of this method is that you can make as many retries as you want, and modify conversion options without affecting your manually converted tags. Of course, if you have an error in your manual work, you have to find a solution to efficiently correct it.

Usage:
------

[](#usage)

```
