1. Go to this page and download the library: Download serhii/goodbye-html 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/ */
serhii / goodbye-html example snippets
use Serhii\GoodbyeHtml\Parser;
$variables = [
'title' => 'Title of the document',
'uses_php_3_years' => true,
'show_container' => false,
];
// Absolute file path to a text file
$file_path = __DIR__ . '/hello.html';
$parser = new Parser($file_path, $variables);
// this will parsed content of hello.html file
echo $parser->parseHtml();
use Serhii\GoodbyeHtml\Parser;
add_shortcode('my_shortcode', 'shortcode_callback');
function shortcode_callback() {
$parser = new Parser(__DIR__ . '/shortcodes/main.html', [
'title' => 'Title of the document',
'uses_php_3_years' => true,
'show_container' => false,
]);
return $parser->parseHtml();
}
html
<!-- Block syntax -->
<section>
{{ if true }}
<h1>PHP is awesome programming language</h1>
{{ end }}
</section>
html
<!-- Inline syntax -->
<h1 class="{{if $show_container}}container{{end}}">
This package is cool
</h1>
html
<!-- Block syntax -->
<section>
{{ if $likes_bread }}
<h1>I like bread</h1>
{{ else }}
<h1>I don't really like bread</h1>
{{ end }}
</section>
html
<!-- Block syntax -->
<section>
{{ if $likes_bread }}
<h1>I like bread</h1>
{{ else if $likes_cake }}
<h1>I like cake</h1>
{{ elseif $likes_pizza }}
<h1>I like pizza</h1>
{{ else }}
<h1>I don't really like anything</h1>
{{ end }}
</section>
html
<!-- Inline syntax -->
<section>
<h1>I like {{ if $likes_bread }}bread{{ else if $likes_cake }}cake{{ else }}just water{{ end }}</h1>
</section>
html
<!-- Inside html attributes -->
<section class="{{ $wrap ? 'container' : '' }}">
<h1>Title</h1>
</section>
html
<!-- With strings -->
<section class="container">
{{ 23 === 23 ? '<h1>Main title</h1>' : '<h2>Secondary</h2>' }}
</section>
html
<!-- With variables -->
<section class="container">
{{ $has_apple ? $with_apple : $without_apple }}
</section>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.