PHP code example of row-bloom / twig-interpolator

1. Go to this page and download the library: Download row-bloom/twig-interpolator 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/ */

    

row-bloom / twig-interpolator example snippets


use RowBloom\RowBloom\Support;
use RowBloom\TwigInterpolator\TwigInterpolator;

app()->get(Support::class);
    ->registerInterpolatorDriver(TwigInterpolator::NAME, TwigInterpolator::class)

use RowBloom\TwigInterpolator\TwigInterpolator;
use RowBloom\RowBloom\Renderers\HtmlRenderer;
use RowBloom\RowBloom\RowBloom;

app()->get(RowBloom::class)
    ->addTable([
        ['title' => 'Title1', 'body' => 'body1'],
        ['title' => 'Title2', 'body' => 'body2'],
    ])
    ->setInterpolator(TwigInterpolator::NAME)
    ->setTemplate('
        <h1>{{ title }}</h1>
        <p>Bold text</p>
        <div>{{ body }}</div>
    ')
    ->setRenderer(HtmlRenderer::class)
    ->save(__DIR__.'/foo.pdf');