PHP code example of edalzell / blade-directives

1. Go to this page and download the library: Download edalzell/blade-directives 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/ */

    

edalzell / blade-directives example snippets


\Statamic\Facades\Antlers::parse($str, /* $variables = [] or collect(get_defined_vars())->except('__data', '__path')->toArray() */)

view('home', ['str' => "{{ 'foo' }}"]);

view('home', [
    'str' => "{{ foo }}",
    'variables' = ['foo' => 'bar']
]);
blade
@php
    $content = '{{ test | ucfirst }}';
    $context = ['test' => 'testing'];
@endphp

This will output Testing.
@antlers($content, $context)
blade
@entry('the_collection_handle', 'entry-slug')
    @foreach($replicator as $set)
        <p>Type is {{ $set['type'] }}</p>
        @
blade
@form('contact_us', ['redirect'=> '/', 'error_redirect' => '', 'allow_request_redirect' => false, 'id' => 'form-id', 'class' => 'foo'])
Email: <input type="text" name="email" />
@error('email', 'form.contact_us')
    <div>{{ $message }}</div>
@enderror
<button>Contact Us</button>
@endform
blade
@formfields('contact_us')
<label>{{ $field['display'] }}</label>
<input type="{{ $field['type'] }}" name="{{ $field['handle'] }}" placeholder="{{ $field['placeholder'] ?? '' }}" />
@endformfields