Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
syna
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Flori
syna
Commits
79b84af0
Commit
79b84af0
authored
6 years ago
by
Thomas Flori
Browse files
Options
Downloads
Patches
Plain Diff
add a readme
parent
98a02347
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+89
-0
89 additions, 0 deletions
README.md
with
89 additions
and
0 deletions
README.md
0 → 100644
+
89
−
0
View file @
79b84af0
# tflori/syna
[

](https://travis-ci.org/tflori/syna)
[

](https://coveralls.io/github/tflori/syna?branch=master)
[

](https://packagist.org/packages/tflori/syna)
[

](https://packagist.org/packages/tflori/syna)
[

](https://packagist.org/packages/tflori/syna)
PHP library for rendering native php templates with sections, inheritance and helpers.
## Installation
Like all my libraries: only with composer
```
console
$
composer require tflori/syna
```
## Basic usage
```
php
<?php
use
Syna\Engine
;
use
Syna\HelperLocator
;
use
Syna\ViewLocator
;
$viewLocator
=
new
ViewLocator
(
__DIR__
.
'/resources/views'
);
$layoutLocator
=
new
ViewLocator
(
__DIR__
.
'/resources/layouts'
);
$helperLocator
=
new
HelperLocator
();
$templates
=
new
Engine
(
$viewLocator
,
$helperLocator
,
$layoutLocator
);
echo
$templates
->
render
(
'pages/home'
,
[],
'fullPage'
);
```
**layouts/fullPage.phtml**
```
php
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Example
</title>
</head>
<body>
<?=
$v
->
fetch
(
'partials/navbar'
)
?>
<div
id=
"content"
>
<?=
$v
->
section
(
'content'
)
?>
</div>
</body>
</html>
```
**views/pages/home**
```
php
<?php
$v
->
extends
(
'pageWithTeaser'
);
?>
<?php
$v
->
start
(
'teaser'
)
?>
<img
src=
"teaser.jpg"
/>
<div
class=
"teaser-content"
>
<h2>
Title for teaser
</h2>
<p>
Lorem ipsum dolor sit amet...
</p>
</div>
<?php
$v
->
end
();
?>
<div
class=
"card"
>
Lorem ipsum dolor sit amet...
</div>
<div
class=
"card"
>
Lorem ipsum dolor sit amet...
</div>
<p>
what ever...
</p>
```
**views/pageWithTeaser**
```
php
<div
class=
"teaser"
>
<?=
$v
->
section
(
'teaser'
)
?>
</div>
<?=
$v
->
section
(
'content'
)
?>
```
Please also have a look at the
[
example
](
example.php
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment