Download the PHP package sunnysideup/reflection-templates without Composer
On this page you can find all versions of the php package sunnysideup/reflection-templates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sunnysideup/reflection-templates
More information about sunnysideup/reflection-templates
Files in sunnysideup/reflection-templates
Package reflection-templates
Short Description Provides introspection of SilverStripe templates with an API for getting variables and blocks, much like the PHP ReflectionClass.
License BSD-3-Clause
Informations about the package reflection-templates
Reflection Templates for SilverStripe
A set of classes that introspect SilverStripe templates, getting metadata about variables and blocks, much like PHP's ReflectionClass.
Installation
composer require unclecheese/reflection-templates:dev-master
Requirements
SilverStripe 3.1 or higher
Usage
Given a template such as this:
We can introspect it using a ReflectionTemplate
like so:
This produces the following result:
Contextual template reflection
You can use one of the two context-sensitive reflectors to surface only variables and blocks that are user-defined.
SiteTreeReflectionTemplate
comes loaded with context about methods and variables that are made available to allSiteTree
andContentController
contexts, and filters out things like$Menu
,$SiteConfig
, etc.EmailReflectionTemplate
works similarly, filtering out variables likeTo
,Subject
, etc., that are made available to all emails.
For all that is good and holy in this world, WHY?!
I found myself in need of it recently, and I had all this code kicking around from the old SilverSmith project, and decided its best not left to sit and rot into oblivion. Hopefully someone else can make use of this insanity.
Todo
Add a task that will generate PHP classes given a template