kevinbaubet / kss-php-markup
An extension of kss-php for get markup by url and html selector.
1.0.1
2018-10-16 12:08 UTC
Requires
- kss-php/kss-php: 2.*
- paquettg/php-html-parser: 1.*
This package is auto-updated.
Last update: 2024-04-17 01:06:17 UTC
README
This is an extension of Knyle Style Sheets PHP (KSS). KSS PHP Markup add a new method to write markup in styles files. The markup can be generated by url and html selector and it can be cached.
Before
/* Markup: <ul class="list list--primary"> <li class="list-item"> <article> <h2>Title</h2> ... ... </article> </li> </ul> Styleguide Lists - Primary */ .list--primary { ... }
After
/* Markup: url(http://site.com/news)->find(.list--primary)->filter(.list-item) Styleguide Lists - Primary */ .list--primary { ... }
PHP library
<?php require_once '../vendor/autoload.php'; $styleguide = new \Kss\Parser('public/stylesheets'); $section = $styleguide->getSection('Lists - Primary'); $markup = new \Kss\Markup($section); echo $markup->getNormal(); // echoes <ul class="list list--primary">...</ul> $markup->flushcache(); // clean all markup cache, if enabled
Syntax
/* Get html markup Markup: url(http://site.com/news)->find(.classSelector) Get html markup with urlPrefix option Markup: url(/news)->find(.classSelector) Get html markup with filter result Markup: url(/news)->find(.classSelector)->filter(.classSelector) Get html markup with filter result and choose length Markup: url(/news)->find(.classSelector)->filter(.classSelector, 4) */
Options
<?php $options = new \StdClass; $options->cache = true; $options->urlPrefix = 'http://site.com'; $markup = new \Kss\Markup($section, $options);
Option | Type | Default | Comment |
---|---|---|---|
cache | boolean | false | Enable cache for store the markup result |
modifier | string | '$modifierClass' | The modifier variable name |
urlPrefix | string | null | Set a prefix url for url() selector |