2017 © Pedro Pelรกez
 

library tempa-php

Template file parsing library

image

icanhazstring/tempa-php

Template file parsing library

  • Monday, August 14, 2017
  • by icanhazstring
  • Repository
  • 0 Watchers
  • 0 Stars
  • 771 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 118 % Grown

The README.md

icanhazstring/tempa-php

Build Status, (*1)

What for?

You all came across some *.dist or *.skel files of some sort. This library can be used to replace every existing substitute in those files as well as simply list them., (*2)

Install

To install this library simply use composer., (*3)

$ composer require icanhazstring/tempa-php

After you have done this you need to create a tempa.json file inside you project. This file holds some basic information about the template files., (*4)

Here is an example, (*5)

{
  "fileExtensions": ["dist", "skel"],
  "prefix": "{$",
  "suffix": "}"
}

Usage

Scan

You can scan a directory or single file using the scan command., (*6)

$ vendor/bin/tempa file:scan <dir> [<config>]

You can deliver every other config you want. By default the script will take the tempa.json from the location you executed the script., (*7)

$ vendor/bin/tempa file:scan test/Demo
$ vendor/bin/tempa file:scan test/Demo test/Demo/tempa.json

Scanning for template files in: /home/icanhazstring/tempa-php/test/Demo
=======================================================================

 2/2 [โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“] 100%


/home/ando/tempa-php/test/Demo/Sub/test.php.dist
------------------------------------------------

Line 3 : 'database' => '{$database}',
Line 4 : 'username' => '{$user}'

/home/ando/tempa-php/test/Demo/test.php.dist
--------------------------------------------

Line 3 : 'placeholder' => '{$superAwesome}'

Substitute

To replace stuff run the following:, (*8)

$ vendor/bin/tempa file:substitute [-f|--mapfile [MAPFILE]] [--] <dir> [<config>] [<map>]... 
$ vendor/bin/tempa file:substitute test/Demo/
$ vendor/bin/tempa file:substitute test/Demo/ --mapfile=test/Demo/maps/map.[json|php]
$ vendor/bin/tempa file:substitute test/Demo/ test/Demo/tempa.json database=localhost user=icanhazstring superAwesome=mega 

Processing template files in: /home/icanhazstring/tempa-php/test/Demo
=====================================================================

 2/2 [โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“] 100%

Interactive

You can replace every with an interactive mode:, (*9)

$ vendor/bin/tempa file:interactive test/Demo
$ vendor/bin/tempa file:interactive test/Demo test/Demo/tempa.json


Interactive substitution for template files in: /home/icanhazstring/tempa-php/test/Demo
=======================================================================================

Found 3 substitutes
-------------------

database:
>

...

The Versions

14/08 2017

dev-master

9999999-dev

Template file parsing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

14/08 2017

v2.0

2.0.0.0

Template file parsing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

09/01 2017

1.1.2

1.1.2.0

Template file parsing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

04/01 2017

1.1.1

1.1.1.0

Template file parsing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

04/01 2017

1.1.0

1.1.0.0

Template file parsing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

03/01 2017

1.0.1

1.0.1.0

Template file parsing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring

02/01 2017

1.0.0

1.0.0.0

Template file parsing library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar icanhazstring