A text file in which specific parts may be replaced.

A template file is a \FeaturePhp\File\StoredFile which is assumed to have text contents. It has rules (see \FeaturePhp\Specification\ReplacementRule) which specify parts of the file to be replaced, enabling simple feature-based templating systems.

package Default
inherited_from \FeaturePhp\File\StoredFile

 Methods

Creates a template file.

__construct(string $fileTarget, string $fileSource, array<mixed,\FeaturePhp\Specification\ReplacementRule> $rules) 
inherited_from \FeaturePhp\File\StoredFile::__construct()

Parameters

$fileTarget

string

$fileSource

string

$rules

array<mixed,\FeaturePhp\Specification\ReplacementRule>

Creates a file.

__construct(string $fileTarget) 
Inherited

Parameters

$fileTarget

string

Adds rules to the template file.

extend(\FeaturePhp\Specification\TemplateSpecification $templateSpecification) : array<mixed,\FeaturePhp\Place\Place>

This is expected to be called only be a \FeaturePhp\Generator\TemplateGenerator. Only uses the rules of the template specification.

inherited_from \FeaturePhp\File\ExtendFile::extend()

Parameters

$templateSpecification

\FeaturePhp\Specification\TemplateSpecification

Returns

array<mixed,\FeaturePhp\Place\Place>

Creates a template file from a template specification.

fromSpecification(\FeaturePhp\Specification\TemplateSpecification $templateSpecification) : \FeaturePhp\File\TemplateFile
Static
inherited_from \FeaturePhp\File\StoredFile::fromSpecification()

Parameters

$templateSpecification

\FeaturePhp\Specification\TemplateSpecification

Returns

\FeaturePhp\File\TemplateFile

Creates a stored file from a file specification.

fromSpecification(\FeaturePhp\Specification\FileSpecification $fileSpecification) : \FeaturePhp\File\StoredFile
InheritedStatic

Parameters

$fileSpecification

\FeaturePhp\Specification\FileSpecification

Returns

\FeaturePhp\File\StoredFile

Returns the template file's content.

getContent() : \FeaturePhp\File\TextFileContent

The content consists of the file content with every rule applied.

inherited_from \FeaturePhp\File\StoredFile::getContent()

Returns

\FeaturePhp\File\TextFileContent

Returns the file's content.

getContent() : \FeaturePhp\File\FileContent
Inherited

Returns

\FeaturePhp\File\FileContent

Returns the file's target.

getTarget() : string
Inherited

Returns

string

A quick way to directly render a template file with some replacement rules.

render(string $source, array<mixed,array> $rules = array(), string $directory = null) : string
Static

Parameters

$source

string

$rules

array<mixed,array>

$directory

string

Returns

string

 Properties

 

a (relative) path to the file on the server

$fileSource : string

Default

 

the file target in the generated product

$fileTarget : string

Default

 

rules to apply to the file content

$rules : array<mixed,\FeaturePhp\Specification\ReplacementRule>

Default