2017 © Pedro Peláez
 

neos-package atomicfusion-constants

Language construct for constants as an addition to Neos.Fusion

image

packagefactory/atomicfusion-constants

Language construct for constants as an addition to Neos.Fusion

  • Wednesday, April 11, 2018
  • by grebaldi
  • Repository
  • 2 Watchers
  • 3 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PackageFactory.AtomicFusion.Constants

Constants as a language construct for fusion, (*1)

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., (*2)

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., (*3)

Installation

PackageFactory.AtomicFusion.Constants is available via packagist. You can install this package with composer:, (*4)

composer require packagefactory/atomicfusion-constants

We use semantic-versioning so every breaking change will increase the major-version number., (*5)

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:, (*6)

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., (*7)

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., (*8)

Magic Constants

__FILE__

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

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., (*10)

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

License

see LICENSE file, (*11)

The Versions

11/04 2018

dev-master

9999999-dev

Language construct for constants as an addition to Neos.Fusion

  Sources   Download

GPL-3.0

The Requires

 

11/04 2018

v1.0.0

1.0.0.0

Language construct for constants as an addition to Neos.Fusion

  Sources   Download

The Requires