Download the PHP package pixo/labcoat without Composer
On this page you can find all versions of the php package pixo/labcoat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package labcoat
Short Description Development tools for Twig
License NCSA
Homepage http://pixotech.com/
Informations about the package labcoat
Labcoat: Pattern Lab for Production
Labcoat is a library for using Pattern Lab content in live site environments. It provides the ability to:
- Render pattern templates
- Generate style guides using the Pattern Lab UI
- Validate template content
Labcoat places the following restrictions on Pattern Lab installations:
- Twig is the only supported templating language
- Patterns can only be referenced by partial and path syntax
- Layouts, macros, and other advanced Twig features are not supported
Labcoat was created by Pixo, and released under the NCSA license.
Pattern Lab was created by Brad Frost and Dave Olsen, and released under the MIT license.
Basic usage
Include the Labcoat library using Composer:
The PatternLab class represents a Pattern Lab installation. For Standard Edition installations, Labcoat needs the path to the installation root (containing config
and source
directories):
For an installation that uses Labcoat's default structure:
For custom configurations, create a new Configuration object and use it as a constructor argument:
- More about Labcoat configuration
Rendering pattern templates
Labcoat contains a Twig loader class for using pattern templates in other applications.
The loader supports two methods of including patterns:
- Partial syntax, i.e.
type-name
. Fuzzy matching is not supported. - Path, relative to the patterns directory. The file extension and any ordering digits are ignored.
Caching the loader
Once created, the loader class can be stored in a cache to save time during the next request. If Memcache is available:
If Stash is being used:
Combining with other loaders
The Labcoat loader can be chained with other loaders:
Creating HTML documents
The Document class makes full HTML pages from patterns:
Generating style guides
Labcoat can generate style guides that use the Pattern Lab interface
Use PHP's built-in webserver to browse the style guide locally (at http://localhost:8080, in this example):
Reporting
The generate()
method returns a report object, which can be printed to obtain a summary of the generation process:
Which produces something like:
To get a full report of style guide file changes, use the verbose()
method of the report:
Validating template content
Labcoat can use pattern data files to validate classes that will represent live content in production environments.
For example, a template named molecules-event
could have the following data file:
In production, the event
variable will be an instance of the Event
class. This class has properties and methods that Twig will treat like attributes of the variable.
Labcoat provides test methods to ensure that the Event
class has all the attributes of event
which are present in the data file.
When this test is run, the output will be something like this: