-
Notifications
You must be signed in to change notification settings - Fork 91
/
example_conditions.php
49 lines (40 loc) · 1.54 KB
/
example_conditions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
* This file belongs to the package "TYPO3 Fluid".
* See LICENSE.txt that was shipped with this package.
*/
/**
* EXAMPLE: Using conditions
*
* This example shows you how to use conditions
* in the Fluid template language, how they behave
* and which syntax they support.
*/
use TYPO3Fluid\FluidExamples\Helper\ExampleHelper;
require_once __DIR__ . '/../vendor/autoload.php';
$exampleHelper = new ExampleHelper();
$view = $exampleHelper->init();
// Assigning View variables: we assign variables that will be used by the
// expressions we build in this example. Refer to the names of these
// variables to understand what goes on.
$view->assign('vartrue', true);
$view->assign('varfalse', false);
$view->assign('vararray1', ['foo' => 'bar']);
$view->assign('vararray2', ['bar' => 'foo']);
$view->assign('checkTernary', true);
$view->assign('ternaryTrue', 'The ternary expression is TRUE');
$view->assign('ternaryFalse', 'The ternary expression is FALSE');
$view->assign('asArray', [
'nested' => [
'then' => 'Dotted variable TRUE',
'else' => 'Dotted variable FALSE',
'check' => true,
],
]);
// Assigning the template path and filename to be rendered. Doing this overrides
// resolving normally done by the TemplatePaths and directly renders this file.
$paths = $view->getTemplatePaths();
$paths->setTemplatePathAndFilename(__DIR__ . '/Resources/Private/Singles/Conditions.html');
// Rendering the View: plain old rendering of single file, no bells and whistles.
$output = $view->render();
$exampleHelper->output($output);