Skip to content

Commit

Permalink
#142 update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tbela99 committed Sep 18, 2022
1 parent ad5dad1 commit ba887b9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,19 @@ $stylesheet->append('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/

## Performance

### Utility methods

The renderer class provides utility methods to format css data

```php

$css = \TBela\CSS\Renderer::fromFile($url_or_file, $renderOptions = [], $parseOptions = []);
#
$css = \TBela\CSS\Renderer::fromString($css, $renderOptions = [], $parseOptions = []);
```

### Manual parsing and rendering

parsing and rendering ast is 3x faster than parsing an element.

```php
Expand All @@ -598,9 +611,12 @@ echo (string) $parser;

// or render minified css
$renderer = new Renderer(['compress' => true]);
echo $renderer->renderAst($parser->getAst());

// slower - will build an Element
echo $renderer->renderAst($parser);
# or
echo $renderer->renderAst($parser->getAst());
# or
// slower - will build a stylesheet object
echo $renderer->render($parser->parse());
```
## Parser Options
Expand Down
26 changes: 24 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ A CSS parser, beautifier and minifier written in PHP. It supports the following

install using [Composer](https://getcomposer.org/)

### PHP version >= 8.0
```bash
$ composer require tbela99/css
```

### PHP version >= 5.6
```bash
$ composer require "tbela99/css:dev-php56-backport"
```

## Requirements

- PHP version >= 8.0 on master branch.
Expand Down Expand Up @@ -578,6 +584,19 @@ $stylesheet->append('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/

## Performance

### Utility methods

The renderer class provides utility methods to format css data

```php

$css = \TBela\CSS\Renderer::fromFile($url_or_file, $renderOptions = [], $parseOptions = []);
#
$css = \TBela\CSS\Renderer::fromString($css, $renderOptions = [], $parseOptions = []);
```

### Manual parsing and rendering

parsing and rendering ast is 3x faster than parsing an element.

```php
Expand All @@ -592,9 +611,12 @@ echo (string) $parser;

// or render minified css
$renderer = new Renderer(['compress' => true]);
echo $renderer->renderAst($parser->getAst());

// slower - will build an Element
echo $renderer->renderAst($parser);
# or
echo $renderer->renderAst($parser->getAst());
# or
// slower - will build a stylesheet object
echo $renderer->render($parser->parse());
```
## Parser Options
Expand Down

0 comments on commit ba887b9

Please sign in to comment.