In the original patternlab-php (as for release 0.7.12) /source
and /public
directories were hard-coded in different places (php, json etc). So the difference here is that the source and the output paths were made configurable via config.ini
. By default both paths are the same as in the original version, but you can change them by tweaking core/config/config.ini.default
before starting the generator for the first time.
NOTES:
- paths should be related to the PatterLab root folder (where
/config
,/core
and/extras
folders are placed). - if a path doesn't exists, all levels will be fully created during the first run
- since paths are now configurable and created automatically, the original
/source
and/public
folders were removed from the project root - both directories could be even outside the PatternLab root folder
For example, these are now quite possible settings in config.ini.default
for paths:
sourceDir = "some/long/path/to/source"
publicDir = "../../../path/could/go/even/outside/patterlab/directory"
P.S. Yes, I noticed that in the original dev
branch some major changes have been done to make these paths configurable, but the last commits were made about a year ago and this work doesn't seemed to be finished. That's why I decided to implement this functionality in a pretty simple way, without huge refactoring of the code. Hope this will allow the community to use PatternLab in a much more flexible way. And of course many thanks to Dave Olsen and all other contributors for this wonderful tool :))
The PHP version of Pattern Lab is, at its core, a static site generator. It combines platform-agnostic assets, like the Mustache-based patterns and the JavaScript-based viewer, with a PHP-based "builder" that transforms and dynamically builds the Pattern Lab site. By making it a static site generator, Pattern Lab strongly separates patterns, data, and presentation from build logic.
You can play with a demo of the front-end of Pattern Lab at demo.patternlab.io.
- Requirements
- Installing the PHP Version of Pattern Lab
- Upgrading the PHP Version of Pattern Lab
- Generating the Pattern Lab Website for the First Time
- Editing the Pattern Lab Website Source Files
- Using the Command-line Options
- Command Prompt on Windows
Patterns are the core element of Pattern Lab. Understanding how they work is the key to getting the most out of the system. Patterns use Mustache so please read Mustache's docs as well.
- How Patterns Are Organized
- Adding New Patterns
- Reorganizing Patterns
- Including One Pattern Within Another via Partials
- Managing Assets for a Pattern: JavaScript, images, CSS, etc.
- Modifying the Pattern Header and Footer
- Using Pseudo-Patterns
- Using Pattern Parameters
- Using Pattern State
- "Hiding" Patterns in the Navigation
- Adding Annotations
- Viewing Patterns on a Mobile Device
The PHP version of Pattern Lab utilizes Mustache as the template language for patterns. In addition to allowing for the inclusion of one pattern within another it also gives pattern developers the ability to include variables. This means that attributes like image sources can be centralized in one file for easy modification across one or more patterns. The PHP version of Pattern Lab uses a JSON file, source/_data/data.json
, to centralize many of these attributes.
- Introduction to JSON & Mustache Variables
- Overriding the Central
data.json
Values with Pattern-specific Values - Linking to Patterns with Pattern Lab's Default
link
Variable - Creating Lists with Pattern Lab's Default
listItems
Variable
By default, the Pattern Lab assets can be manually generated and the Pattern Lab site manually refreshed but who wants to waste time doing that? Here are some ways that Pattern Lab can make your development workflow a little smoother:
- Watching for Changes and Auto-Regenerating Patterns
- Auto-Reloading the Browser Window When Changes Are Made
- Multi-browser & Multi-device Testing with Page Follow
- Keyboard Shortcuts
- Special Pattern Lab-specific Query String Variables
- Preventing the Cleaning of public/
- Generating CSS
- Modifying the Pattern Lab Nav
- Editing the config.ini Options
- Integration with Compass