PHP code example of ubertech-za / asciidoc-renderer
1. Go to this page and download the library: Download ubertech-za/asciidoc-renderer 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/ */
ubertech-za / asciidoc-renderer example snippets
use UbertechZa\AsciidocRenderer\Facades\Asciidoc;
$asciidoc = Asciidoc::render('adoc::my-document', [
'title' => 'My Amazing Project',
'author' => 'John Doe',
'date' => '2025-01-01'
]);
// Or render directly to file
Asciidoc::renderToFile('adoc::my-document', $data, '/path/to/output.adoc');
namespace App\Asciidoc\Components;
use Illuminate\View\Component;
class DataTable extends Component
{
public function __construct(
public array $headers,
public array $rows,
public ?string $title = null
) {}
public function render()
{
return view('adoc::components.data-table');
}
}
use UbertechZa\AsciidocRenderer\Contracts\TemplateRenderer;
class MyCustomRenderer implements TemplateRenderer
{
public function render(string $template, array $data = []): string
{
// Your custom rendering logic
}
}
// Bind in a service provider
$this->app->bind(TemplateRenderer::class, MyCustomRenderer::class);
use UbertechZa\AsciidocRenderer\AsciidocGenerator;
use UbertechZa\AsciidocRenderer\Rendering\BladeRenderer;
$generator = new AsciidocGenerator(
new BladeRenderer(app('view'))
);
$output = $generator->render('my-template', $data);
$generator->renderToFile('my-template', $data, '/path/to/file.adoc');