packagefactory/atomicfusion-constants

Last activity on 4 April 2018
  • 3
  • 6
composer require packagefactory/atomicfusion-constants

Language construct for constants as an addition to Neos.Fusion

v1.0.0

Language construct for constants as an addition to Neos.Fusion

Version
v1.0.0
Type
neos-package
Release Date
11.04.2018 15:26:52
Source
git
Distribution
zip
Requires
Requires (dev)
None
Suggest
None
Provides
None
Conflicts
None
Replaces
None
92469b70c28e881cdc302e4a729e7f12f01d34f8

PackageFactory.AtomicFusion.Constants

Constants as a language construct for fusion

Warning!

This is experimental technology. Constants are currently not part of the fusion language. You can however install this package to make this functionality available to your project.

Our goal is to make this part of the fusion core in the future. It is very likely though, that Syntax, Scoping and implementation details will deviate from what is presented here.

Installation

PackageFactory.AtomicFusion.Constants is available via packagist. You can install this package with composer:

composer require packagefactory/atomicfusion-constants

We use semantic-versioning so every breaking change will increase the major-version number.

Usage

This package introduces the const: declaration, that let's you define constants within a fusion file. With const::* you can use the defined constant anywhere in your fusion file:

const: PI = 3.14

prototype(Vendor.Site:MyCircleArea) < prototype(PackageFactory.AtomicFusion:Component) {
	radius = 5
	renderer = ${const::PI * props.radius * props.radius}
}

Constants are scoped to the file they are defined in and cannot be overwritten or redeclared within that file.

Constant names need to be ALL_UPPERCASE and can contain letters, numbers and underscores. A name needs to start with either a letter or an underscore.

Magic Constants

__FILE__

Similar to PHP's __FILE__ constant, you can use const::__FILE__ to reference the location of the current fusion file.

prototype(Vendor.Site:MyContentElement) < prototype(Neos.Fusion:Template) {
	@process.attachFileName = ${value + '<br>Brought to you by ' + const::__FILE__}
}

__DIR__

Similar to PHP's __DIR__ constant, you can use const::__DIR__ to reference the directory of the current fusion file.

prototype(Vendor.Site:MyContentElement) < prototype(Neos.Fusion:Template) {
	templatePath = ${const::__DIR__ + '/MyContentElement.html'}
}

License

see LICENSE file

The content of the readme is provided by Github
The same vendor provides 12 package(s).