PHP code example of phpinnacle / stylus
1. Go to this page and download the library: Download phpinnacle/stylus library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpinnacle / stylus example snippets
// config/livewire.php
'payload' => [
// Keep the other Livewire payload guards unchanged.
'max_nesting_depth' => 20,
],
use PHPinnacle\Stylus\Forms\ContentEditor;
use PHPinnacle\Stylus\Forms\RichEditor;
ContentEditor::make('content')->
public array $template = [
'version' => 1,
'document' => [
'type' => 'doc',
'content' => [
[
'type' => 'paragraph',
'content' => [
['type' => 'text', 'text' => 'Hello '],
[
'type' => 'twigVariable',
'attrs' => [
'expression' => 'user.name',
'filters' => [],
],
],
],
],
],
],
'template' => '<p>Hello {{ user.name }}</p>',
];
use Filament\Support\Icons\Heroicon;
use PHPinnacle\Stylus\BuiltInCatalog;
use PHPinnacle\Stylus\Forms\TwigEditor;
use PHPinnacle\Stylus\Snippet;
use PHPinnacle\Stylus\Variable;
TwigEditor::make('template')
->variables(
Variable::make('user', 'user')
->label('User')
->icon(Heroicon::User)
->description('Customer profile fields')
->color('info')
->group('User')
->properties(
Variable::text('name')->label('User name')->sample('Ada Lovelace'),
Variable::text('email')->label('User email'),
),
Variable::collection('orders')
->label('Orders')
->items(
Variable::make('order', 'order')
->properties(
Variable::text('number')->label('Order number'),
Variable::collection('lines')->items(
Variable::make('line', 'line')->properties(
Variable::text('description'),
Variable::make('amount', 'number'),
),
keyType: 'integer',
),
),
keyType: 'integer',
),
)
->filters(...BuiltInCatalog::filters())
->conditions(...BuiltInCatalog::conditions())
->snippets(
Snippet::make('account_signature', [[
'type' => 'paragraph',
'content' => [
['type' => 'text', 'text' => 'Kind regards, '],
[
'type' => 'twigVariable',
'attrs' => ['expression' => 'user.name', 'filters' => []],
],
],
]])
->label('Account signature')
->icon(Heroicon::User)
->description('Reusable customer sign-off')
->color('info')
->
$state = $this->form->getState();
$template = $state['template']['template'];
use PHPinnacle\Stylus\Twig\TwigTemplateValidator;
$result = (new TwigTemplateValidator($twig))->validate($template['template']);
bash
php artisan livewire:publish --config