/
NeosFusionReference.rst
1389 lines (995 loc) · 50.8 KB
/
NeosFusionReference.rst
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.. _neos-Fusion-reference:
================
Fusion Reference
================
Neos.Fusion
===========
This package contains general-purpose Fusion objects, which are usable both within Neos and standalone.
.. _Neos_Fusion__Join:
Neos.Fusion:Join
----------------
Render multiple nested definitions and concatenate the results.
:[key]: (string) A nested definition (simple value, expression or object) that evaluates to a string
:[key].@ignoreProperties: (array) A list of properties to ignore from being "rendered" during evaluation
:[key].@position: (string/integer) Define the ordering of the nested definition
:@glue: (string) The glue used to join the items together (default = '').
The order in which nested definitions are evaluated are specified using their
``@position`` meta property. For this argument, the following sort order applies:
* ``start [priority]`` positions. The higher the priority, the earlier
the object is added. If no priority is given, the element is sorted after all
``start`` elements with a priority.
* ``[numeric ordering]`` positions, ordered ascending.
* ``end [priority]`` positions. The higher the priority, the later the element is
added. If no priority is given, the element is sorted before all ``end`` elements
with a priority.
Furthermore, you can specify that an element should be inserted before or after a given
other named element, using ``before`` and ``after`` syntax as follows:
* ``before [namedElement] [optionalPriority]``: add this element before ``namedElement``;
the higher the priority the more in front of ``namedElement`` we will add it if multiple
``before [namedElement]`` statements exist. Statements without ``[optionalPriority]``
are added the farthest before the element.
If ``[namedElement]`` does not exist, the element is added after all ``start`` positions.
* ``after [namedElement] [optionalPriority]``: add this element after ``namedElement``;
the higher the priority the more closely after ``namedElement`` we will add it if multiple
``after [namedElement]`` statements exist. Statements without ``[optionalPriority]``
are added farthest after the element.
If ``[namedElement]`` does not exist, the element is added before all all ``end`` positions.
Example Ordering::
# in this example, we would not need to use any @position property;
# as the default (document order) would then be used. However, the
# order (o1 ... o9) is *always* fixed, no matter in which order the
# individual statements are defined.
myString = Neos.Fusion:Join {
o1 = Neos.NodeTypes:Text
o1.@position = 'start 12'
o2 = Neos.NodeTypes:Text
o2.@position = 'start 5'
o2 = Neos.NodeTypes:Text
o2.@position = 'start'
o3 = Neos.NodeTypes:Text
o3.@position = '10'
o4 = Neos.NodeTypes:Text
o4.@position = '20'
o5 = Neos.NodeTypes:Text
o5.@position = 'before o6'
o6 = Neos.NodeTypes:Text
o6.@position = 'end'
o7 = Neos.NodeTypes:Text
o7.@position = 'end 20'
o8 = Neos.NodeTypes:Text
o8.@position = 'end 30'
o9 = Neos.NodeTypes:Text
o9.@position = 'after o8'
}
If no ``@position`` property is defined, the array key is used. However, we suggest
to use ``@position`` and meaningful keys in your application, and not numeric ones.
Example of numeric keys (discouraged)::
myString = Neos.Fusion:Join {
10 = Neos.NodeTypes:Text
20 = Neos.NodeTypes:Text
}
.. _Neos_Fusion__Loop:
Neos.Fusion:Loop
----------------
Render each item in ``items`` using ``itemRenderer``.
:items: (array/Iterable, **required**) The array or iterable to iterate over (to calculate ``iterator.isLast`` items have to be ``countable``)
:itemName: (string, defaults to ``item``) Context variable name for each item
:itemKey: (string, defaults to ``itemKey``) Context variable name for each item key, when working with array
:iterationName: (string, defaults to ``iterator``) A context variable with iteration information will be available under the given name: ``index`` (zero-based), ``cycle`` (1-based), ``isFirst``, ``isLast``
:itemRenderer: (string, **required**) The renderer definition (simple value, expression or object) will be called once for every collection element, and its results will be concatenated (if ``itemRenderer`` cannot be rendered the path ``content`` is used as fallback for convenience in afx)
:@glue: (string) The glue used to join the items together (default = '').
Example using an object ``itemRenderer``::
myLoop = Neos.Fusion:Loop {
items = ${[1, 2, 3]}
itemName = 'element'
itemRenderer = Neos.Fusion:Template {
templatePath = 'resource://...'
element = ${element}
}
}
Example using an expression ``itemRenderer``::
myLoop = Neos.Fusion:Loop {
items = ${[1, 2, 3]}
itemName = 'element'
itemRenderer = ${element * 2}
}
.. _Neos_Fusion__Map:
Neos.Fusion:Map
---------------
Render each item in ``items`` using ``itemRenderer`` and return the result as an array (opposed to *string* for :ref:`Neos_Fusion__Join`)
:items: (array/Iterable, **required**) The array or iterable to iterate over (to calculate ``iterator.isLast`` items have to be ``countable``)
:itemName: (string, defaults to ``item``) Context variable name for each item
:itemKey: (string, defaults to ``itemKey``) Context variable name for each item key, when working with array
:iterationName: (string, defaults to ``iterator``) A context variable with iteration information will be available under the given name: ``index`` (zero-based), ``cycle`` (1-based), ``isFirst``, ``isLast``
:itemRenderer: (mixed, **required**) The renderer definition (simple value, expression or object) will be called once for every collection element to render the item (if ``itemRenderer`` cannot be rendered the path ``content`` is used as fallback for convenience in afx)
:keyRenderer: (mixed, **optional**) The renderer definition (simple value, expression or object) will be called once for every collection element to render the key in the result collection.
.. _Neos_Fusion__Reduce:
Neos.Fusion:Reduce
------------------
Reduce the given items to a single value by using ``itemReducer``.
:items: (array/Iterable, **required**) The array or iterable to iterate over (to calculate ``iterator.isLast`` items have to be ``countable``)
:itemName: (string, defaults to ``item``) Context variable name for each item
:itemKey: (string, defaults to ``itemKey``) Context variable name for each item key, when working with array
:carryName: (string, defaults to ``carry``) Context variable that contains the result of the last iteration
:iterationName: (string, defaults to ``iterator``) A context variable with iteration information will be available under the given name: ``index`` (zero-based), ``cycle`` (1-based), ``isFirst``, ``isLast``
:itemReducer: (mixed, **required**) The reducer definition (simple value, expression or object) that will be applied for every item.
:initialValue: (mixed, defaults to ``null``) The value that is passed to the first iteration or returned if the items are empty
.. _Neos_Fusion__Case:
Neos.Fusion:Case
----------------
**Conditionally evaluate** nested definitions.
Evaluates all nested definitions until the first ``condition`` evaluates to ``TRUE``. The Case object will
evaluate to a result using either ``renderer``, ``renderPath`` or ``type`` on the matching definition.
:[key]: A matcher definition
:[key].condition: (boolean, **required**) A simple value, expression or object that will be used as a condition for this matcher
:[key].type: (string) Object type to render (as string)
:[key].element.*: (mixed) Properties for the rendered object (when using ``type``)
:[key].renderPath: (string) Relative or absolute path to render, overrules ``type``
:[key].renderer: (mixed) Rendering definition (simple value, expression or object), overrules ``renderPath`` and ``type``
:[key].@position: (string/integer) Define the ordering of the nested definition
Simple Example::
myCase = Neos.Fusion:Case {
someCondition {
condition = ${q(node).is('[instanceof MyNamespace:My.Special.SuperType]')}
type = 'MyNamespace:My.Special.Type'
}
otherCondition {
@position = 'start'
condition = ${q(documentNode).property('layout') == 'special'}
renderer = ${'<marquee>' + q(node).property('content') + '</marquee>'}
}
fallback {
condition = ${true}
renderPath = '/myPath'
}
}
The ordering of matcher definitions can be specified with the ``@position`` property (see :ref:`Neos_Fusion__Join`).
Thus, the priority of existing matchers (e.g. the default Neos document rendering) can be changed by setting or
overriding the ``@position`` property.
.. note:: The internal ``Neos.Fusion:Matcher`` object type is used to evaluate the matcher definitions which
is based on the ``Neos.Fusion:Renderer``.
.. _Neos_Fusion__Renderer:
Neos.Fusion:Renderer
--------------------
The Renderer object will evaluate to a result using either ``renderer``, ``renderPath`` or ``type`` from the configuration.
:type: (string) Object type to render (as string)
:element.*: (mixed) Properties for the rendered object (when using ``type``)
:renderPath: (string) Relative or absolute path to render, overrules ``type``
:renderer: (mixed) Rendering definition (simple value, expression or object), overrules ``renderPath`` and ``type``
Simple Example::
myCase = Neos.Fusion:Renderer {
type = 'Neos.Fusion:Value'
element.value = 'hello World'
}
.. note:: This is especially handy if the prototype that should be rendered is determined via eel or passed via @context.
.. _Neos_Fusion__Debug:
Neos.Fusion:Debug
-----------------
Shows the result of Fusion Expressions directly.
:title: (optional) Title for the debug output
:plaintext: (boolean) If set true, the result will be shown as plaintext
:[key]: (mixed) A nested definition (simple value, expression or object), ``[key]`` will be used as key for the resulting output
Example::
valueToDebug = "hello neos world"
valueToDebug.@process.debug = Neos.Fusion:Debug {
title = 'Debug of hello world'
# Additional values for debugging
documentTitle = ${q(documentNode).property('title')}
documentPath = ${documentNode.path}
}
# the initial value is not changed, so you can define the Debug prototype anywhere in your Fusion code
.. _Neos_Fusion__Debug_Console:
Neos.Fusion:Debug.Console
-----------------
Wraps the given value with a script tag to print it to the browser console.
When used as process the script tag is appended to the processed value.
:title: (optional) Title for the debug output
:value: (mixed) The value to print to the console
:method: (string, optional) The method to call on the browser console object
:[key]: (mixed) Other arguments to pass to the console method
Example::
renderer.@process.debug = Neos.Fusion:Debug.Console {
title = 'My props'
value = ${props}
method = 'table'
}
Multiple values::
renderer.@process.debug = Neos.Fusion:Debug.Console {
value = ${props.foo}
otherValue = ${props.other}
thirdValue = ${props.third}
}
Color usage::
renderer.@process.debug = Neos.Fusion:Debug.Console {
value = ${'%c' + node.identifier}
color = 'color: red'
}
.. _Neos_Fusion__Component:
Neos.Fusion:Component
---------------------
Create a component
:[key]: (mixed) The public API of your component: Lazy evaluated props that will be available inside the current component's scope under the context ``props`` (is iterable)
:@private.[key]: (mixed) Can only be set inside the root component declaration: Lazy evaluated private props that will be available inside the current component's scope under the context ``private`` (is not iterable / is only a proxy)
:renderer: (mixed, **required**) The value which gets rendered
.. note:: The context ``props`` and ``private`` is only available in the components scope
The component's scope will be available inside the `renderer` and `@private` and will extend inwards until inside another component's renderer
That means inside `@private` it's even allowed to reference another private prop (be carefully of circular references, though!)
But normal props are not inside the component's scope and thus cannot reference each other or ``private``
Example::
prototype(Vendor.Site:Component) < prototype(Neos.Fusion:Component) {
title = 'Hello World'
titleTagName = 'h1'
bold = false
@private {
computedTitle = ${String.toLowercase(props.title)}
funnyTitle = Neos.Fusion:Value {
value = ${props.titleTagName + " " + private.computedTitle}
}
}
renderer = Neos.Fusion:Tag {
attributes.class {
component = 'component'
bold = ${props.bold && 'component--bold'}
}
content = Neos.Fusion:Join {
headline = Neos.Fusion:Tag {
tagName = ${props.titleTagName}
content = ${private.funnyTitle}
}
// nestedComponentScope = Neos.Fusion:Component {
// prop1 = ${props.title} // works
// renderer = ${props.title} // doest work!
// }
}
}
}
.. _Neos_Fusion__Fragment:
Neos.Fusion:Fragment
--------------------
A fragment is a component that renders the given `content` without additional markup.
That way conditions can be defined for bigger chunks of afx instead of single tags.
:content: (string) The value which gets rendered
Example::
renderer = afx`
<Neos.Fusion:Fragment @if.isEnabled={props.enable}>
<h1>Example</h1>
<h2>Content</h2>
</Neos.Fusion:Fragment>
`
.. _Neos_Fusion__Augmenter:
Neos.Fusion:Augmenter
---------------------
Modify given html content and add attributes. The augmenter can be used as processor or as a standalone prototype
:content: (string) The content that shall be augmented
:fallbackTagName: (string, defaults to ``div``) If no single tag that can be augmented is found the content is wrapped into the fallback-tag before augmentation
:[key]: All other fusion properties are added to the html content as html attributes
Example as a standalone augmenter::
augmentedContent = Neos.Fusion:Augmenter {
content = Neos.Fusion:Join {
title = Neos.Fusion:Tag {
@if.hasContent = ${this.content}
tagName = 'h2'
content = ${q(node).property('title')}
}
text = Neos.Fusion:Tag {
@if.hasContent = ${this.content}
tagName = 'p'
content = ${q(node).property('text')}
}
}
fallbackTagName = 'header'
class = 'header'
data-foo = 'bar'
}
Example as a processor augmenter::
augmentedContent = Neos.Fusion:Tag {
tagName = 'h2'
content = 'Hello World'
@process.augment = Neos.Fusion:Augmenter {
class = 'header'
data-foo = 'bar'
}
}
.. _Neos_Fusion__Template:
Neos.Fusion:Template
--------------------
Render a *Fluid template* specified by ``templatePath``.
:templatePath: (string, **required**) Path and filename for the template to be rendered, often a ``resource://`` URI
:partialRootPath: (string) Path where partials are found on the file system
:layoutRootPath: (string) Path where layouts are found on the file system
:sectionName: (string) The Fluid ``<f:section>`` to be rendered, if given
:[key]: (mixed) All remaining properties are directly passed into the Fluid template as template variables
Example::
myTemplate = Neos.Fusion:Template {
templatePath = 'resource://My.Package/Private/Templates/FusionObjects/MyTemplate.html'
someDataAvailableInsideFluid = 'my data'
}
<div class="hero">
{someDataAvailableInsideFluid}
</div>
.. _Neos_Fusion__Value:
Neos.Fusion:Value
-----------------
Evaluate any value as a Fusion object
:value: (mixed, **required**) The value to evaluate
Example::
myValue = Neos.Fusion:Value {
value = 'Hello World'
}
.. note:: Most of the time this can be simplified by directly assigning the value instead of using the ``Value`` object.
.. _Neos_Fusion__Match:
Neos.Fusion:Match
-----------------
Matches the given subject to a value
:@subject: (string, **required**) The subject to match
:@default: (mixed) The default to return when no match was found
:[key]: (mixed) Definition list, the keys will be matched to the subject and their value returned.
Example::
myValue = Neos.Fusion:Match {
@subject = 'hello'
@default = 'World?'
hello = 'Hello World'
bye = 'Goodbye world'
}
.. note:: This can be used to simplify many usages of :ref:`Neos_Fusion__Case` when the subject is a string.
.. _Neos_Fusion__Memo:
Neos.Fusion:Memo
-----------------
Returns the result of previous calls with the same "discriminator"
:discriminator: (string, **required**) Cache identifier
:value: (mixed) The value to evaluate and store for future calls during rendering
Example::
prototype(My.Vendor:Expensive.Calculation) < prototype(Neos.Fusion:Memo) {
discriminator = 'expensive-calculation'
value = ${1+2}
}
.. _Neos_Fusion__DataStructure:
Neos.Fusion:DataStructure
--------------------
Evaluate nested definitions as an array (opposed to *string* for :ref:`Neos_Fusion__Join`)
:[key]: (mixed) A nested definition (simple value, expression or object), ``[key]`` will be used for the resulting array key
:[key].@position: (string/integer) Define the ordering of the nested definition
.. tip:: For simple cases an expression with an array literal ``${[1, 2, 3]}`` might be easier to read
.. _Neos_Fusion__Tag:
Neos.Fusion:Tag
---------------
Render an HTML tag with attributes and optional body
:tagName: (string) Tag name of the HTML element, defaults to ``div``
:omitClosingTag: (boolean) Whether to render the element ``content`` and the closing tag, defaults to ``FALSE``
:selfClosingTag: (boolean) Whether the tag is a self-closing tag with no closing tag. Will be resolved from ``tagName`` by default, so default HTML tags are treated correctly.
:content: (string) The inner content of the element, will only be rendered if the tag is not self-closing and the closing tag is not omitted
:attributes: (iterable) Tag attributes as key-value pairs. Default is ``Neos.Fusion:DataStructure``. If a non iterable is returned the value is casted to string.
:allowEmptyAttributes: (boolean) Whether empty attributes (HTML5 syntax) should be used for empty, false or null attribute values. By default this is ``true``
Example:
^^^^^^^^
::
htmlTag = Neos.Fusion:Tag {
tagName = 'html'
omitClosingTag = TRUE
attributes {
version = 'HTML+RDFa 1.1'
xmlns = 'http://www.w3.org/1999/xhtml'
}
}
Evaluates to::
<html version="HTML+RDFa 1.1" xmlns="http://www.w3.org/1999/xhtml">
.. _Neos_Fusion__Http_Message:
Neos.Fusion:Http.Message
------------------------
A prototype based on :ref:`Neos_Fusion__Join` for rendering an HTTP message (response). It should be used to
render documents since it generates a full HTTP response and allows to override the HTTP status code and headers.
:httpResponseHead: (:ref:`Neos_Fusion__Http_ResponseHead`) An HTTP response head with properties to adjust the status and headers, the position in the ``Join`` defaults to the very beginning
:[key]: (string) A nested definition (see :ref:`Neos_Fusion__Join`)
Example:
^^^^^^^^
::
// Page extends from Http.Message
//
// prototype(Neos.Neos:Page) < prototype(Neos.Fusion:Http.Message)
//
page = Neos.Neos:Page {
httpResponseHead.headers.Content-Type = 'application/json'
}
.. _Neos_Fusion__Http_ResponseHead:
Neos.Fusion:Http.ResponseHead
-----------------------------
A helper object to render the head of an HTTP response
:statusCode: (integer) The HTTP status code for the response, defaults to ``200``
:headers.*: (string) An HTTP header that should be set on the response, the property name (e.g. ``headers.Content-Type``) will be used for the header name
.. _Neos_Fusion__ActionUri:
Neos.Fusion:ActionUri
---------------------
Built a URI to a controller action
:request: (ActionRequest, defaults to the the current ``request``) The action request the uri is build from.
:package: (string) The package key (e.g. ``'My.Package'``)
:subpackage: (string) The subpackage, empty by default
:controller: (string) The controller name (e.g. ``'Registration'``)
:action: (string) The action name (e.g. ``'new'``)
:arguments: (array) Arguments to the action by named key
:format: (string) An optional request format (e.g. ``'html'``)
:section: (string) An optional fragment (hash) for the URI
:additionalParams: (array) Additional URI query parameters by named key
:addQueryString: (boolean) Whether to keep the query parameters of the current URI
:argumentsToBeExcludedFromQueryString: (array) Query parameters to exclude for ``addQueryString``
:absolute: (boolean) Whether to create an absolute URI
Example::
uri = Neos.Fusion:ActionUri {
package = 'My.Package'
controller = 'Registration'
action = 'new'
}
A special case is generating URIs for links to Neos modules. In this case often the option `request = ${request.mainRequest}` is needed
when linking to a controller outside of the context of the current subrequest.
Link to the content module::
uri = Neos.Fusion:ActionUri {
request = ${request.mainRequest}
package="Neos.Neos.Ui"
controller="Backend"
action = 'index'
arguments.node = ${documentNode}
}
Link to backend modules (other than `content`)::
uri = Neos.Fusion:ActionUri {
request = ${request.mainRequest}
action = "index"
package = "Neos.Neos"
controller = "Backend\\Module"
arguments {
module = 'administration/sites'
moduleArguments {
@action = 'edit'
site = ${site}
}
}
}
.. _Neos_Fusion__ResourceUri:
Neos.Fusion:ResourceUri
-----------------------
Build a URI to a static or persisted resource
:path: (string) Path to resource, either a path relative to ``Public`` and ``package`` or a ``resource://`` URI
:package: (string) The package key (e.g. ``'My.Package'``)
:resource: (Resource) A ``Resource`` object instead of ``path`` and ``package``
:localize: (boolean) Whether resource localization should be used, defaults to ``true``
Example::
scriptInclude = Neos.Fusion:Tag {
tagName = 'script'
attributes {
src = Neos.Fusion:ResourceUri {
path = 'resource://My.Package/Public/Scripts/App.js'
}
}
}
.. _Neos_Fusion__Link_Action:
Neos.Fusion:Link.Action
-----------------------
Renders a link pointing to a controller/action
:content: (string) content of the link tag
:href: (string, default :ref:`Neos_Fusion__ActionUri`) The href for the link tag
:[key]: (string) Other attributes for the link tag
Example::
link = Neos.Fusion:Link.Action {
content = "register"
class="action-link"
href.package = 'My.Package'
href.controller = 'Registration'
href.action = 'new'
}
link = afx`
<Neos.Fusion:Link.Action class="action-link" href.package="My.Package" href.controller="Registration" href.action="new">
register
</Neos.Fusion:Link.Action>
`
Link to the content-module in afx::
<Neos.Fusion:Link.Action
href.request={request.mainRequest}
href.action="index"
href.package="Neos.Neos.Ui"
href.controller="Backend"
href.arguments.node={node}
>
to content module
</Neos.Fusion:Link.Action>
Link to backend-modules other than the content-module::
<Neos.Fusion:Link.Action
href.request={request.mainRequest}
href.action="index"
href.package="Neos.Neos"
href.controller="Backend\\Module"
href.arguments.module='administration/sites'
href.arguments.moduleArguments.@action='index'
>
to site module
</Neos.Fusion:Link.Action>
.. _Neos_Fusion__Link_Resource:
Neos.Fusion:Link.Resource
-------------------------
Renders a link pointing to a resource
:content: (string) content of the link tag
:href: (string, default :ref:`Neos_Fusion__ResourceUri`) The href for the link tag
:[key]: (string) Other attributes for the link tag
Example::
link = afx`
<Neos.Fusion:Link.Resource class="resource-link" href.path="resource://Some.Package/Public/Images/SomeImage.png">
Some Link
</Neos.Fusion:Link.Resource>
`
Neos.Fusion:CanRender
---------------------
Check whether a Fusion prototype can be rendered. For being renderable a prototype must exist and have an implementation class, or inherit from an existing renderable prototype. The implementation class can be defined indirectly via base prototypes.
:type: (string) The prototype name that is checked
:path: (string) The fusion path name that is checked
Example::
canRender = Neos.Fusion:CanRender {
type = 'My.Package:Prototype'
}
Neos.Neos Fusion Objects
=============================
The Fusion objects defined in the Neos package contain all Fusion objects which
are needed to integrate a site. Often, it contains generic Fusion objects
which do not need a particular node type to work on.
.. _Neos_Neos__Page:
Neos.Neos:Page
--------------
Subclass of :ref:`Neos_Fusion__Http_Message`, which is based on :ref:`Neos_Fusion__Join`. Main entry point
into rendering a page; responsible for rendering the ``<html>`` tag and everything inside.
:doctype: (string) Defaults to ``<!DOCTYPE html>``
:htmlTag: (:ref:`Neos_Fusion__Tag`) The opening ``<html>`` tag
:htmlTag.attributes: (:ref:`Neos_Fusion__DataStructure`) Attributes for the ``<html>`` tag
:headTag: (:ref:`Neos_Fusion__Tag`) The opening ``<head>`` tag
:head: (:ref:`Neos_Fusion__Join`) HTML markup for the ``<head>`` tag
:head.titleTag: (:ref:`Neos_Fusion__Tag`) The ``<title>`` tag
:head.javascripts: (:ref:`Neos_Fusion__Join`) Script includes in the head should go here
:head.stylesheets: (:ref:`Neos_Fusion__Join`) Link tags for stylesheets in the head should go here
:bodyTag: (:ref:`Neos_Fusion__Tag`) The opening ``<body>`` tag
:bodyTag.attributes: (:ref:`Neos_Fusion__DataStructure`) Attributes for the ``<body>`` tag
:body: (:ref:`Neos_Fusion__Join`) HTML markup for the ``<body>`` tag.
:body.javascripts: (:ref:`Neos_Fusion__Join`) Body footer JavaScript includes
Examples:
^^^^^^^^^
Rendering a simple page:
""""""""""""""""""""""""
Fusion::
page = Neos.Neos:Page
page.body {
header = Vendor.Site:Fragment.Header
content = afx`
<div class="container">
<Neos.Neos:ContentCollection nodePath="main"/>
</div>
`
footer = Vendor.Site:Fragment.Header
}
Including stylesheets from a template section in the head:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Fusion::
page.head.stylesheets {
mySite = afx`
<link rel="stylesheet" href={StaticResource.uri('Vendor.Site', 'Public/Styles/Main.css')} />
`
}
Adding body attributes with ``bodyTag.attributes``:
"""""""""""""""""""""""""""""""""""""""""""""""""""
::
page.bodyTag.attributes.class = 'body-css-class1 body-css-class2'
.. _Neos_Neos__ContentCollection:
Neos.Neos:ContentCollection
---------------------------
Render nested content from a ``ContentCollection`` node. Individual nodes are rendered using the
:ref:`Neos_Neos__ContentCase` object.
:nodePath: (string, **required**) The relative node path of the ``ContentCollection`` (e.g. ``'main'``)
:@context.node: (Node) The content collection node, resolved from ``nodePath`` by default
:tagName: (string) Tag name for the wrapper element
:attributes: (:ref:`Neos_Fusion__DataStructure`) Tag attributes for the wrapper element
Example::
page.body {
content {
main = Neos.Neos:ContentCollection {
nodePath = 'main'
}
footer = Neos.Neos:ContentCollection {
nodePath = 'footer'
}
}
}
.. _Neos_Neos__ContentCase:
Neos.Neos:ContentCase
---------------------
Render a content node, extends :ref:`Neos_Fusion__Case`. This is a prototype that is used by the default content
rendering (:ref:`Neos_Neos__ContentCollection`) and can be extended to add custom matchers.
:default: Default matcher that renders a prototype of the same name as the node type name
:[key]: Additional matchers (see :ref:`Neos_Fusion__Case`)
.. _Neos_Neos__Content:
Neos.Neos:Content
-----------------
Base type to render content nodes, extends :ref:`Neos_Fusion__Template`. This prototype is extended by the
auto-generated Fusion to define prototypes for each node type extending ``Neos.Neos:Content``.
:templatePath: (string) The template path and filename, defaults to ``'resource://[packageKey]/Private/Templates/NodeTypes/[nodeType].html'`` (for auto-generated prototypes)
:[key]: (mixed) Template variables, all node type properties are available by default (for auto-generated prototypes)
:attributes: (:ref:`Neos_Fusion__DataStructure`) Extensible attributes, used in the default templates
Example::
prototype(My.Package:MyContent) < prototype(Neos.Neos:Content) {
templatePath = 'resource://My.Package/Private/Templates/NodeTypes/MyContent.html'
# Auto-generated for all node type properties
# title = ${q(node).property('title')}
}
.. _Neos_Neos__ContentComponent:
Neos.Neos:ContentComponent
--------------------------
Base type to render component based content-nodes, extends :ref:`Neos_Fusion__Component`.
Features the same API as :ref:`Neos_Fusion__Component`, but it adds content element wrapping, so the node is correctly detected by the Neos.Ui
.. _Neos_Neos__Editable:
Neos.Neos:Editable
------------------
Create an editable tag for a property. In the frontend, only the content of the property gets rendered.
:node: (node) A node instance that should be used to read the property. Default to `${node}`
:property: (string) The name of the property which should be accessed
:block: (boolean) Decides if the editable tag should be a block element (`div`) or an inline element (`span`). Default to `true`
Example::
title = Neos.Neos:Editable {
property = 'title'
block = false
}
.. _Neos_Neos__Plugin:
Neos.Neos:Plugin
----------------
Base type to render plugin content nodes or static plugins. A *plugin* is a Flow controller that can implement
arbitrary logic.
:package: (string, **required**) The package key (e.g. `'My.Package'`)
:subpackage: (string) The subpackage, defaults to empty
:controller: (array) The controller name (e.g. 'Registration')
:action: (string) The action name, defaults to `'index'`
:argumentNamespace: (string) Namespace for action arguments, will be resolved from node type by default
:[key]: (mixed) Pass an internal argument to the controller action (access with argument name ``__key``)
Example::
prototype(My.Site:Registration) < prototype(Neos.Neos:Plugin) {
package = 'My.Site'
controller = 'Registration'
}
Example with argument passed to controller action::
prototype(My.Site:Registration) < prototype(Neos.Neos:Plugin) {
package = 'My.Site'
controller = 'Registration'
action = 'register'
additionalArgument = 'foo'
}
Get argument in controller action::
public function registerAction()
{
$additionalArgument = $this->request->getInternalArgument('__additionalArgument');
[...]
}
.. _Neos_Neos__Menu:
Neos.Neos:Menu
--------------
Render a menu with items for nodes.
:attributes: (:ref:`Neos_Fusion__DataStructure`) attributes for the whole menu
The following properties are passed over to :ref:`Neos_Neos__MenuItems` internally:
:node: (Node) The current node used to calculate the itemStates, and ``startingPoint`` (if not defined explicitly). Defaults to ``node`` from the fusion context
:entryLevel: (integer) Define the startingPoint of the menu relatively. Non negative values specify this as n levels below root. Negative values are n steps up from ``node`` or ``startingPoint`` if defined. Defaults to ``1`` if no ``startingPoint`` is set otherwise ``0``
:lastLevel: (optional, integer) Restrict the depth of the menu relatively. Positive values specify this as n levels below root. Negative values specify this as n steps up from ``node``. Defaults to ``null``
:maximumLevels: (integer) Restrict the maximum depth of items in the menu (relative to ``entryLevel``)
:startingPoint: (optional, Node) The node where the menu hierarchy starts. If not specified explicitly the startingPoint is calculated from (``node`` and ``entryLevel``), defaults to ``null``
:filter: (string) Filter items by node type (e.g. ``'!My.Site:News,Neos.Neos:Document'``), defaults to ``'Neos.Neos:Document'``. The filter is only used for fetching subItems and is ignored for determining the ``startingPoint``
:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered, defaults to ``false``
:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false``.
:itemCollection: (optional, array of Nodes) Explicitly set the Node items for the menu (taking precedence over ``startingPoints`` and ``entryLevel`` and ``lastLevel``). The children for each ``Node`` will be fetched taking the ``maximumLevels`` property into account.
Example::
menu = Neos.Neos:Menu {
attributes.class = 'menu'
maximumLevels = 3
}
.. note:: The ``items`` of the ``Menu`` are internally calculated with the prototype :ref:`Neos_Neos__MenuItems` which
you can use directly aswell.
.. note:: The ``rendering`` of the ``Menu`` is performed with the prototype :ref:`Neos_Neos__MenuItemListRenderer`.
If the rendering does not suit your useCase it we recommended to create your own variants of the menu and renderer prototype.
.. _Neos_Neos__BreadcrumbMenu:
Neos.Neos:BreadcrumbMenu
------------------------
Render a breadcrumb (ancestor documents).
:attributes: (:ref:`Neos_Fusion__DataStructure`) html attributes for the rendered list
The following properties are passed over to :ref:`Neos_Neos__BreadcrumbMenuItems` internally:
:node: (Node) The current node to render the menu for. Defaults to ``documentNode`` from the fusion context
:maximumLevels: (integer) Restrict the maximum depth of items in the menu, defaults to ``0``
:renderHiddenInIndex: (boolean) Whether nodes with ``hiddenInIndex`` should be rendered (the current documentNode is always included), defaults to ``false``.
:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false``
Example::
breadcrumb = Neos.Neos:BreadcrumbMenu
.. note:: The ``items`` of the ``BreadcrumbMenu`` are internally calculated with the prototype :ref:`Neos_Neos__MenuItems` which
you can use directly aswell.
.. note:: The ``rendering`` of the ``BreadcrumbMenu`` is performed with the prototype :ref:`Neos_Neos__MenuItemListRenderer`.
If the rendering does not suit your useCase it we recommended to create your own variants of the menu and renderer prototype.
.. _Neos_Neos__DimensionMenu:
.. _Neos_Neos__DimensionsMenu:
Neos.Neos:DimensionsMenu
------------------------
Create links to other node variants (e.g. variants of the current node in other dimensions).
:attributes: (:ref:`Neos_Fusion__DataStructure`) attributes for the whole menu
The following fusion properties are passed over to :ref:`Neos_Neos__DimensionsMenuItems` internally:
:node: (Node) The current node used to calculate the Menu. Defaults to ``documentNode`` from the fusion context
:dimension: (optional, string): name of the dimension which this menu should be based on. Example: "language".
:presets: (optional, array): If set, the presets rendered will be taken from this list of preset identifiers
:includeAllPresets: (boolean, default **false**) If TRUE, include all presets, not only allowed combinations
:renderHiddenInIndex: (boolean, default **true**) If TRUE, render nodes which are marked as "hidded-in-index"
:calculateItemStates: (boolean) activate the *expensive* calculation of item states defaults to ``false``
.. note:: The ``items`` of the ``DimensionsMenu`` are internally calculated with the prototype :ref:`Neos_Neos__DimensionsMenuItems` which
you can use directly aswell.
.. note:: The ``rendering`` of the ``DimensionsMenu`` is performed with the prototype :ref:`Neos_Neos__MenuItemListRenderer`.
If the rendering does not suit your useCase it we recommended to create your own variants of the menu and renderer prototype.
.. _Neos_Neos__MenuItemListRenderer:
Neos.Neos:MenuItemListRenderer