Skip to content

develhopper/Primal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Primal

Yet another templating engine library

Documentation

Installation

composer require develhopper/primal

Examples

Initialize Primal

<?php
use Primal\Primal;

$primal = Primal::getInstance([
'views_dir' => 'views directory',
'cache_dir' => 'directory path for caching'
]);

$primal->view("viewname.html",[
'arg1' => 'value'
]); // it will print the content of the view file 

Views Syntax

Print a variable
<h1>
{{$variable}}
</h1>
Execute a Function
{% var_dump($array); %}
Include another view
@include('viewname.html')
Place holder

"base.html"

<body>
@yield('content')
</body>
Extend from another view
@extend('base.html')
Fill Placeholder in base.html with content by @section
@extend('base.html')

@section('content')
<h1>{{$title}}</h1>
<p>{{$content}}</p>
@endsection
If Else and elseif Statements
@if($variable == "foo")
<p>foo</p>
@elseif($variable == "bar")
<p>bar</p>
@else
<p>foobar</p>
@endif
For and Foreach Loops
@for($i=0;$i<100;$i++)
<p>{{$i}}</p>
@endfor

@foreach($list as $item)
<p>{{$item}}</p>
@endforeach

About

php templating engine

Resources

Stars

Watchers

Forks

Packages

No packages published