Twig

Implements \phpDocumentor\Plugin\Scrybe\Template\TemplateInterface

Template class to use Twig to generate templates.

package

Default

Methods

Constructs the twig template and sets the default values.

__construct(string $templatePath) 

Arguments

$templatePath

string

the base location for templates.

Applies the relevant template upon the given content.

decorate(string $contents, array<mixed,string> $options = array()) : string

This method takes the combines the template with the given contents and generates a final piece of text from that.

The user may add additional options that are set as parameters in the template.

see \phpDocumentor\Plugin\Scrybe\Template\getTemplateFileName()

how the filename is assembled

Arguments

$contents

string

$options

array<mixed,string>

Response

string

Returns a list of files that need to be copied to the destination location.

getAssets() : array<mixed,string>

Examples of assets can be:

  • CSS files
  • Javascript files
  • Images

Assets for this template engine means every file that is contained in a subfolder of the template folder and does not end with the extension twig.

Thus every file in the root of the template folder is ignored and files and directories having only twig templates (considered as being includes) are not included in this list.

Response

array<mixed,string>

Returns the extension of the destination file extension.

getExtension() : string
see \phpDocumentor\Plugin\Scrybe\Template\setExtension

for more information and the format of the extension.

Response

string

Returns the name of this template.

getName() : string

See setName() for a specification of the format.

Response

string

Returns the base path where the templates are stored.

getPath() : string

Response

string

Returns the filename for the template.

getTemplateFilename() : string

The filename is composed of the following components:

  • the template base folder
  • the template's name
  • a path separator
  • the literal 'layout' combined with the extension
  • and as final extension the literal '.twig'
Throws
\DomainException

if the template does not exist.

Response

string

Constructs and returns the twig environment.

getTwigEnvironment() : \Twig_Environment

This uses the path as defined with this class to instantiate a new Environment and disables the escaping mechanism since we use it to generate HTML; even embedded.

see \phpDocumentor\Plugin\Scrybe\Template\Twig::path

for the template base path.

Response

\Twig_Environment

Sets the file extension used to determine the template filename.

setExtension(string $extension) : void

The file extension of the destination format needs to be set. This is used to retrieve the correct template.

Throws
\InvalidArgumentException

if the extension does not match the validation restrictions mentioned above.

Arguments

$extension

string

an extension (thus only containing alphanumeric characters and be between 2 and 4 characters in size).

Sets the name for this template.

setName(string $name) : void
Throws
\InvalidArgumentException

if the name does not match the prescribed format.

Arguments

$name

string

A template name that may be composed of alphanumeric characters, underscores and/or hyphens.

Sets the base path where the templates are stored.

setPath(string $path) : void
Throws
\InvalidArgumentException

Arguments

$path

string

Properties

The base location for templates

path : string
var

The base location for templates

Type(s)

string

The name of the containing template folder

name : string
var

The name of the containing template folder

Type(s)

string

The extension used to select the correct template file

extension : string
var

The extension used to select the correct template file

Type(s)

string