PHTML Project
Convert PHTML code to pure PHP
you have to use it with another packages like Gulp
Installation
$ npm install gulp
$ npm install rt-phtml --save-dev
task example with Gulp
const gulp = require('gulp');
const phtml = require('rt-phtml');
gulp.task('test', function () {
return gulp.src('./src/index.phtml')
.pipe(phtml())
.pipe(gulp.dest('./dist'));
});
PHTML Code exampels
Echo Variable
<strong>{{ @RAGGI }}</strong>
Result:
<strong><?=$RAGGI ?></strong>
Get function result
<strong>@@func_sum(1,2,3,4,5)</strong>
Result:
<strong><?=func_sum(1,2,3,4,5) ?></strong>
if / elseif / else
<span>
@if (@RAGGI == 10)
YES
@elseif (@RAGGI == 15)
NO
@else
UNKNOWN
@endif
</span>
Result:
<span>
<?php if ($RAGGI == 10): ?>
YES
<?php elseif ($RAGGI == 15): ?>
NO
<?php else: ?>
UNKNOWN
<?php @endif; ?>
</span>
each & endeach || foreach & endforeach / for & endfor / while & endwhile
you can use @item without key in @each
<span>
@each @key, @item in @items
{{ @key }} - {{ @item }} <br>
@endeach
</span>
Result:
<span>
<?php foreach ($items as $key => $item): ?>
<?=$key ?> - <?=$item ?> <br>
<?php endforeach; ?>
</span>
Author
License
MIT
Free Software!