\Tale\Jade\Renderer\AdapterFile

Handles rendering with cached files and include.

This is the best adapter for production systems, cheap VPS or any hosts that don't have 'allow_url_fopen' activated

The following happens:

  1. The jade gets rendered to markup
  2. The markup is saved into a .phtml-file
  3. The .phtml-file is included

Advantages:

  • Caching integrated
  • Next to memory-caching probably the fastest way to render
  • Good debugging, especially then compiler:pretty is activated
  • No special configuration needed

Disadvantages:

  • You need a cache-directory (Though, most websites have one anyways)
  • It needs some configuration in the most cases
  • Cache files should be secured, since it's PHP-code!!! (e.g. Deny in .htaccess)

Summary

Methods
Properties
Constants
__construct()
getRenderer()
render()
No public properties found
No constants found
getOption()
No protected properties found
N/A
No private methods found
$_renderer
$_options
N/A

Properties

$_renderer

$_renderer : \Tale\Jade\Renderer

The renderer this adapter got created in.

Type

\Tale\Jade\Renderer

$_options

$_options : array

The options array for this adapter.

Type

array

Methods

__construct()

__construct(\Tale\Jade\Renderer  $renderer, array|null  $options = null) 

Creates a new File renderer adapter.

If the cache directory doesn't exist, it tries to automatically create it

Possible options are: path: The path where rendered files are stored extension: The extension we should store the files with (Default: .phtml) lifeTime: The Cache lifeTime (Set to 0 to disable cache), (Default: 0)

Parameters

\Tale\Jade\Renderer $renderer

the renderer instance this renderer was created in

array|null $options

the options array for this renderer adapter

Throws

\Exception

when the Cache Directory is not writable

getRenderer()

getRenderer() : \Tale\Jade\Renderer

Returns the attached renderer this adapter was created in.

Returns

\Tale\Jade\Renderer

render()

render(string  $path, array|null  $args = null) : string

Renders a jade file by a given path.

The extension can be omitted if it's the extension set in the Compiler-options ('.jade' by default)

The given $args-argument should be an associative array and will be passed as variables that you can use inside the rendered template file

Notice that the path is relative to the Compiler-option 'paths' or, if no paths passed, the paths in get_include_path()

You might just echo the result, cache it or do anything else with it

Parameters

string $path

the relative path to be rendered

array|null $args

the variables for the template

Throws

\Exception

when the directory can't be created

\Tale\Jade\Compiler\Exception

when the file to render wasnt found

Returns

string —

the rendered markup

getOption()

getOption(string  $name) : mixed

Returns an option by a given name.

The existence of the option is not checked

Parameters

string $name

the name of the option

Returns

mixed —

the value of the option