Dep: update
주로 PHAN
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
name: docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v3
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: '0.79.1'
|
||||
|
||||
- name: Build
|
||||
run: hugo --minify -s doc
|
||||
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./doc/public
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
name: PHP
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
runs-on: 'ubuntu-latest'
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['7.3', '7.4', '8.0']
|
||||
phpunit-versions: ['9.5']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: mbstring, intl
|
||||
ini-values: post_max_size=256M, max_execution_time=180
|
||||
coverage: xdebug
|
||||
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
|
||||
|
||||
- name: Validate Composer
|
||||
run: composer validate
|
||||
- name: Install Composer Deps
|
||||
run: composer install
|
||||
- name: Run Tests
|
||||
run: phpunit --testdox --coverage-text --coverage-clover=coverage.clover
|
||||
- name: Upload Scrutinzer
|
||||
continue-on-error: true
|
||||
run: |
|
||||
wget https://scrutinizer-ci.com/ocular.phar
|
||||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
||||
Vendored
+7
@@ -19,4 +19,11 @@ We accept contributions via Pull Requests on [Github](https://github.com/thephpl
|
||||
``` bash
|
||||
$ phpunit
|
||||
```
|
||||
|
||||
## Docs
|
||||
|
||||
Docs are served with hugo running on version 0.79 or later.
|
||||
|
||||
You can view the docs locally with `hugo -s doc server`
|
||||
|
||||
**Happy coding**!
|
||||
Vendored
+13
-12
@@ -1,11 +1,11 @@
|
||||
Plates
|
||||
======
|
||||
|
||||
[](https://twitter.com/reinink)
|
||||
[](https://twitter.com/ragboyjr)
|
||||
[](https://github.com/thephpleague/plates)
|
||||
[](https://github.com/thephpleague/plates/releases)
|
||||
[](LICENSE)
|
||||
[](https://travis-ci.org/thephpleague/plates)
|
||||
[](https://github.com/thephpleague/plates/actions?query=workflow%3APHP+branch%3Av3)
|
||||
[](https://scrutinizer-ci.com/g/thephpleague/plates/code-structure)
|
||||
[](https://scrutinizer-ci.com/g/thephpleague/plates)
|
||||
[](https://packagist.org/packages/league/plates)
|
||||
@@ -14,15 +14,15 @@ Plates is a native PHP template system that's fast, easy to use and easy to exte
|
||||
|
||||
### Highlights
|
||||
|
||||
- Native PHP templates, no new [syntax](http://platesphp.com/templates/syntax/) to learn
|
||||
- Native PHP templates, no new [syntax](https://platesphp.com/templates/syntax/) to learn
|
||||
- Plates is a template system, not a template language
|
||||
- Plates encourages the use of existing PHP functions
|
||||
- Increase code reuse with template [layouts](http://platesphp.com/templates/layouts/) and [inheritance](http://platesphp.com/templates/inheritance/)
|
||||
- Template [folders](http://platesphp.com/engine/folders/) for grouping templates into namespaces
|
||||
- [Data](http://platesphp.com/templates/data/#preassigned-and-shared-data) sharing across templates
|
||||
- Preassign [data](http://platesphp.com/templates/data/#preassigned-and-shared-data) to specific templates
|
||||
- Built-in [escaping](http://platesphp.com/templates/escaping/) helpers
|
||||
- Easy to extend using [functions](http://platesphp.com/engine/functions/) and [extensions](http://platesphp.com/engine/extensions/)
|
||||
- Increase code reuse with template [layouts](https://platesphp.com/templates/layouts/) and [inheritance](https://platesphp.com/templates/inheritance/)
|
||||
- Template [folders](https://platesphp.com/engine/folders/) for grouping templates into namespaces
|
||||
- [Data](https://platesphp.com/templates/data/#preassigned-and-shared-data) sharing across templates
|
||||
- Preassign [data](https://platesphp.com/templates/data/#preassigned-and-shared-data) to specific templates
|
||||
- Built-in [escaping](https://platesphp.com/templates/escaping/) helpers
|
||||
- Easy to extend using [functions](https://platesphp.com/engine/functions/) and [extensions](https://platesphp.com/engine/extensions/)
|
||||
- Framework-agnostic, will work with any project
|
||||
- Decoupled design makes templates easy to test
|
||||
- Composer ready and PSR-2 compliant
|
||||
@@ -37,7 +37,7 @@ composer require league/plates
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation can be found at [platesphp.com](http://platesphp.com/).
|
||||
Full documentation can be found at [platesphp.com](https://platesphp.com/).
|
||||
|
||||
## Testing
|
||||
|
||||
@@ -51,11 +51,12 @@ Please see [CONTRIBUTING](https://github.com/thephpleague/plates/blob/master/CON
|
||||
|
||||
## Security
|
||||
|
||||
If you discover any security related issues, please email jonathan@reinink.ca instead of using the issue tracker.
|
||||
If you discover any security related issues, please email ragboyjr@icloud.com instead of using the issue tracker.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Jonathan Reinink](https://github.com/reinink)
|
||||
- [RJ Garcia](https://github.com/ragboyjr) (Current Maintainer)
|
||||
- [Jonathan Reinink](https://github.com/reinink) (Original Author)
|
||||
- [All Contributors](https://github.com/thephpleague/plates/contributors)
|
||||
|
||||
## License
|
||||
|
||||
Vendored
+17
-6
@@ -8,34 +8,45 @@
|
||||
"templates",
|
||||
"views"
|
||||
],
|
||||
"homepage": "http://platesphp.com",
|
||||
"homepage": "https://platesphp.com",
|
||||
"license": "MIT",
|
||||
"authors" : [
|
||||
{
|
||||
"name": "Jonathan Reinink",
|
||||
"email": "jonathan@reinink.ca",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "RJ Garcia",
|
||||
"email": "ragboyjr@icloud.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require" : {
|
||||
"php": "^5.3 | ^7.0"
|
||||
"php": "^7.0|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mikey179/vfsStream": "^1.4",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"squizlabs/php_codesniffer": "~1.5"
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"League\\Plates\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"League\\Plates\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phpunit"
|
||||
"test": "phpunit --testdox",
|
||||
"docs": "hugo -s doc server"
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
baseURL = "https://platesphp.com/"
|
||||
languageCode = "en-us"
|
||||
title = "Plates"
|
||||
|
||||
pygmentsUseClasses = true
|
||||
|
||||
googleAnalytics = "UA-46050814-2"
|
||||
|
||||
[params]
|
||||
tagline = "Native PHP Templates"
|
||||
description = "Plates is a Twig inspired, native PHP template system that brings modern template language functionality to native PHP templates."
|
||||
[params.images]
|
||||
favicon = "favicon/favicon.ico"
|
||||
appleTouch = "favicon/apple-touch-icon-precomposed.png"
|
||||
logo = "images/logo.png"
|
||||
+18
-19
@@ -1,17 +1,16 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: /
|
||||
title: Introduction
|
||||
---
|
||||
+++
|
||||
title = "Introduction"
|
||||
[menu.main]
|
||||
parent = "getting-started"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
[](https://twitter.com/reinink)
|
||||
[](https://twitter.com/reinink)
|
||||
[](https://github.com/thephpleague/plates)
|
||||
[](https://github.com/thephpleague/plates/releases)
|
||||
[](https://github.com/thephpleague/plates/blob/master/LICENSE)<br />
|
||||
[](https://travis-ci.org/thephpleague/plates)
|
||||
[](https://github.com/thephpleague/plates/blob/master/LICENSE)
|
||||
{{<html>}}<br/>{{</html>}}
|
||||
[](https://github.com/thephpleague/plates/actions?query=workflow%3APHP+branch%3Av3)
|
||||
[](https://scrutinizer-ci.com/g/thephpleague/plates/code-structure)
|
||||
[](https://scrutinizer-ci.com/g/thephpleague/plates)
|
||||
[](https://packagist.org/packages/league/plates)
|
||||
@@ -22,19 +21,19 @@ Plates is a native PHP template system that's fast, easy to use and easy to exte
|
||||
|
||||
## Highlights
|
||||
|
||||
- Native PHP templates, no new [syntax](/templates/syntax/) to learn
|
||||
- Native PHP templates, no new [syntax]({{< relref "templates/syntax.md" >}}) to learn
|
||||
- Plates is a template system, not a template language
|
||||
- Plates encourages the use of existing PHP functions
|
||||
- Increase code reuse with template [layouts](/templates/layouts/) and [inheritance](/templates/inheritance/)
|
||||
- Template [folders](/engine/folders/) for grouping templates into namespaces
|
||||
- [Data](/templates/data/#preassigned-and-shared-data) sharing across templates
|
||||
- Preassign [data](/templates/data/#preassigned-and-shared-data) to specific templates
|
||||
- Built-in [escaping](/templates/escaping/) helpers
|
||||
- Easy to extend using [functions](/engine/functions/) and [extensions](/engine/extensions/)
|
||||
- Increase code reuse with template [layouts]({{< relref "templates/layouts.md" >}}) and [inheritance]({{< relref "templates/inheritance.md" >}})
|
||||
- Template [folders]({{< relref "engine/folders.md" >}}) for grouping templates into namespaces
|
||||
- [Data]({{< relref "templates/data.md#preassigned-and-shared-data" >}}) sharing across templates
|
||||
- Preassign [data]({{< relref "templates/data#preassigned-and-shared-data" >}}) to specific templates
|
||||
- Built-in [escaping]({{< relref "templates/escaping.md" >}}) helpers
|
||||
- Easy to extend using [functions]({{< relref "engine/functions.md" >}}) and [extensions]({{< relref "engine/extensions.md" >}})
|
||||
- Framework-agnostic, will work with any project
|
||||
- Decoupled design makes templates easy to test
|
||||
- Composer ready and PSR-2 compliant
|
||||
|
||||
## Questions?
|
||||
|
||||
Plates was created by [Jonathan Reinink](https://twitter.com/reinink). Submit issues to [Github](https://github.com/thephpleague/plates/issues).
|
||||
Plates is maintained by [RJ Garcia](https://twitter.com/ragboyjr) and originally created by [Jonathan Reinink](https://twitter.com/reinink). Submit issues to [Github](https://github.com/thephpleague/plates/issues).
|
||||
@@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "The Engine"
|
||||
[menu.main]
|
||||
identifier = "engine"
|
||||
weight = 2
|
||||
+++
|
||||
+11
-12
@@ -1,13 +1,12 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: engine/extensions/
|
||||
title: Extensions
|
||||
---
|
||||
+++
|
||||
title = "Extensions"
|
||||
linkTitle = "Engine Extensions"
|
||||
[menu.main]
|
||||
parent = "engine"
|
||||
weight = 5
|
||||
+++
|
||||
|
||||
Extensions
|
||||
==========
|
||||
|
||||
Creating extensions couldn't be easier, and can really make Plates sing for your specific project. Start by creating a class that implements `\League\Plates\Extension\ExtensionInterface`. Next, register your template [functions](/engine/functions/) within a `register()` method.
|
||||
Creating extensions couldn't be easier, and can really make Plates sing for your specific project. Start by creating a class that implements `\League\Plates\Extension\ExtensionInterface`. Next, register your template [functions]({{< relref "engine/functions.md" >}}) within a `register()` method.
|
||||
|
||||
## Simple extensions example
|
||||
|
||||
@@ -41,7 +40,7 @@ To use this extension in your template, simply call your new functions:
|
||||
<p>Hello, <?=$this->e($this->uppercase($name))?></p>
|
||||
~~~
|
||||
|
||||
They can also be used in a [batch](/templates/functions/#batch-function-calls) compatible function:
|
||||
They can also be used in a [batch]({{< relref "templates/functions.md#batch-function-calls" >}}) compatible function:
|
||||
|
||||
~~~ php
|
||||
<h1>Hello <?=$this->e($name, 'uppercase')</h1>
|
||||
@@ -87,7 +86,7 @@ To use this extension in your template, first call the primary function, then th
|
||||
|
||||
## Loading extensions
|
||||
|
||||
To enable an extension, load it into the [engine](/engine/) object using the `loadExtension()` method.
|
||||
To enable an extension, load it into the [engine]({{< relref "engine/overview.md" >}}) object using the `loadExtension()` method.
|
||||
|
||||
~~~ php
|
||||
$engine->loadExtension(new ChangeCase());
|
||||
@@ -117,4 +116,4 @@ class MyExtension implements ExtensionInterface
|
||||
// ...
|
||||
}
|
||||
}
|
||||
~~~
|
||||
~~~
|
||||
+7
-8
@@ -1,11 +1,10 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: engine/file-extensions/
|
||||
title: File extensions
|
||||
---
|
||||
|
||||
File extensions
|
||||
===============
|
||||
+++
|
||||
title = "File Extensions"
|
||||
linkTitle = "Engine File Extensions"
|
||||
[menu.main]
|
||||
parent = "engine"
|
||||
weight = 2
|
||||
+++
|
||||
|
||||
Plates does not enforce a specific template file extension. By default it assumes `.php`. This file extension is automatically appended to your template names when rendered. You are welcome to change the default extension using one of the following methods.
|
||||
|
||||
Vendored
+7
-8
@@ -1,11 +1,10 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: engine/folders/
|
||||
title: Folders
|
||||
---
|
||||
|
||||
Folders
|
||||
=======
|
||||
+++
|
||||
title = "Folders"
|
||||
linkTitle = "Engine Folders"
|
||||
[menu.main]
|
||||
parent = "engine"
|
||||
weight = 3
|
||||
+++
|
||||
|
||||
Folders make it really easy to organize and access your templates. Folders allow you to group your templates under different namespaces, each of which having their own file system path.
|
||||
|
||||
vendor/league/plates/docs/engine/functions.md → vendor/league/plates/doc/content/engine/functions.md
Vendored
+10
-11
@@ -1,13 +1,12 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: engine/functions/
|
||||
title: Functions
|
||||
---
|
||||
+++
|
||||
title = "Functions"
|
||||
linkTitle = "Engine Functions"
|
||||
[menu.main]
|
||||
parent = "engine"
|
||||
weight = 4
|
||||
+++
|
||||
|
||||
Functions
|
||||
=========
|
||||
|
||||
While [extensions](/engine/extensions/) are awesome for adding additional reusable functionality to Plates, sometimes it's easier to just create a one-off function for a specific use case. Plates makes this easy to do.
|
||||
While [extensions]({{< relref "engine/extensions.md" >}}) are awesome for adding additional reusable functionality to Plates, sometimes it's easier to just create a one-off function for a specific use case. Plates makes this easy to do.
|
||||
|
||||
## Registering functions
|
||||
|
||||
@@ -27,8 +26,8 @@ To use this function in a template, simply call it like any other function:
|
||||
<h1>Hello <?=$this->e($this->uppercase($name))</h1>
|
||||
~~~
|
||||
|
||||
It can also be used in a [batch](/templates/functions/#batch-function-calls) compatible function:
|
||||
It can also be used in a [batch]({{< relref "templates/functions#batch-function-calls">}}) compatible function:
|
||||
|
||||
~~~ php
|
||||
<h1>Hello <?=$this->e($name, 'uppercase')</h1>
|
||||
~~~
|
||||
~~~
|
||||
Vendored
+10
-10
@@ -1,11 +1,11 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: engine/
|
||||
title: The Engine
|
||||
---
|
||||
|
||||
The Engine
|
||||
==========
|
||||
+++
|
||||
title = "Overview"
|
||||
linkTitle = "Engine Overview"
|
||||
aliases = ["/engine"]
|
||||
[menu.main]
|
||||
parent = "engine"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
Plates uses a central object called the `Engine`, which is used to store the environment configuration, functions and extensions. It helps decouple your templates from the file system and other dependencies. For example, if you want to change the folder where your templates are stored, you can do so by simply changing the path in one location.
|
||||
|
||||
@@ -15,7 +15,7 @@ Plates uses a central object called the `Engine`, which is used to store the env
|
||||
// Create new Plates engine
|
||||
$templates = new League\Plates\Engine('/path/to/templates');
|
||||
|
||||
// Add any any additional folders
|
||||
// Add any additional folders
|
||||
$templates->addFolder('emails', '/path/to/emails');
|
||||
|
||||
// Load any additional extensions
|
||||
@@ -53,4 +53,4 @@ class Controller
|
||||
return $this->templates->render('home');
|
||||
}
|
||||
}
|
||||
~~~
|
||||
~~~
|
||||
@@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "Extensions"
|
||||
[menu.main]
|
||||
identifier = "extensions"
|
||||
weight = 4
|
||||
+++
|
||||
vendor/league/plates/docs/extensions/asset.md → vendor/league/plates/doc/content/extensions/asset.md
Vendored
+6
-8
@@ -1,11 +1,9 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: extensions/asset/
|
||||
title: Asset extension
|
||||
---
|
||||
|
||||
Asset
|
||||
=====
|
||||
+++
|
||||
title = "Asset"
|
||||
[menu.main]
|
||||
parent = "extensions"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
The asset extension can be used to quickly create "cache busted" asset URLs in your templates. This is particularly helpful for aggressively cached files that can potentially change in the future, such as CSS files, JavaScript files and images. It works by appending the timestamp of the file's last update to its URL. For example, `/css/all.css` becomes `/css/all.1373577602.css`. As long as the file does not change, the timestamp remains the same and caching occurs. However, if the file is changed, a new URL is automatically generated with a new timestamp, and visitors receive the new file.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
+++
|
||||
title = "Community"
|
||||
[menu.main]
|
||||
parent = "extensions"
|
||||
weight = 3
|
||||
+++
|
||||
|
||||
This is a list of all the known community extensions for the Plates library. Please feel free to submit a [Pull Request](https://github.com/thephpleague/plates) to add your extension to this list.
|
||||
|
||||
- [Laravel Provider](https://github.com/franzliedke/laravel-plates)
|
||||
- [Attributes Rendering](https://github.com/RobinDev/platesAttributes) - Transforms arrays into html tag attributes.
|
||||
- [Includer](https://github.com/odahcam/plates-includer) - Include your assets in an expert way.
|
||||
- [Tapestry](https://github.com/tapestry-cloud/tapestry) - A blog aware, Plates based static site generator.
|
||||
Vendored
+6
-8
@@ -1,11 +1,9 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: extensions/uri/
|
||||
title: URI extension
|
||||
---
|
||||
|
||||
URI
|
||||
===
|
||||
+++
|
||||
title = "URI"
|
||||
[menu.main]
|
||||
parent = "extensions"
|
||||
weight = 2
|
||||
+++
|
||||
|
||||
The URI extension is designed to make URI checks within templates easier. The most common use is marking the current page in a menu as "selected". It only has one function, `uri()`, but can do a number of helpful tasks depending on the parameters passed to it.
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "Getting Started"
|
||||
[menu.main]
|
||||
identifier = "getting-started"
|
||||
weight = 1
|
||||
+++
|
||||
+7
-9
@@ -1,11 +1,9 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: installation/
|
||||
title: Installation
|
||||
---
|
||||
|
||||
Installation
|
||||
============
|
||||
+++
|
||||
title = "Installation"
|
||||
[menu.main]
|
||||
parent = "getting-started"
|
||||
weight = 3
|
||||
+++
|
||||
|
||||
## Using Composer
|
||||
|
||||
@@ -15,7 +13,7 @@ Plates is available on [Packagist](https://packagist.org/packages/league/plates)
|
||||
composer require league/plates
|
||||
~~~
|
||||
|
||||
<div class="filename">composer.json</div>
|
||||
{{< code-filename composer.json >}}
|
||||
~~~ javascript
|
||||
{
|
||||
"require": {
|
||||
+13
-17
@@ -1,11 +1,9 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: simple-example/
|
||||
title: Simple example
|
||||
---
|
||||
|
||||
Simple example
|
||||
==============
|
||||
+++
|
||||
title = "Simple Example"
|
||||
[menu.main]
|
||||
parent = "getting-started"
|
||||
weight = 2
|
||||
+++
|
||||
|
||||
Here is a simple example of how to use Plates. We will assume the following directory stucture:
|
||||
|
||||
@@ -29,7 +27,7 @@ echo $templates->render('profile', ['name' => 'Jonathan']);
|
||||
|
||||
## The page template
|
||||
|
||||
<div class="filename">profile.php</div>
|
||||
{{< code-filename profile.php >}}
|
||||
~~~ php
|
||||
<?php $this->layout('template', ['title' => 'User Profile']) ?>
|
||||
|
||||
@@ -39,16 +37,14 @@ echo $templates->render('profile', ['name' => 'Jonathan']);
|
||||
|
||||
## The layout template
|
||||
|
||||
<div class="filename">template.php</div>
|
||||
{{< code-filename template.php >}}
|
||||
~~~ php
|
||||
<html>
|
||||
<head>
|
||||
<head>
|
||||
<title><?=$this->e($title)?></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?=$this->section('content')?>
|
||||
|
||||
</body>
|
||||
</head>
|
||||
<body>
|
||||
<?=$this->section('content')?>
|
||||
</body>
|
||||
</html>
|
||||
~~~
|
||||
@@ -0,0 +1,6 @@
|
||||
+++
|
||||
title = "Templates"
|
||||
[menu.main]
|
||||
identifier = "templates"
|
||||
weight = 3
|
||||
+++
|
||||
Vendored
+9
-10
@@ -1,11 +1,10 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/data/
|
||||
title: Data
|
||||
---
|
||||
|
||||
Data
|
||||
====
|
||||
+++
|
||||
title = "Data"
|
||||
linkTitle = "Templates Data"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 2
|
||||
+++
|
||||
|
||||
It's very common to share application data (variables) with a template. Data can be whatever you want: strings, arrays, objects, etc. Plates allows you set both template specific data as well as shared template data.
|
||||
|
||||
@@ -30,7 +29,7 @@ $template->data(['name' => 'Jonathan']);
|
||||
|
||||
## Accessing data
|
||||
|
||||
Template data is available as locally scoped variables at the time of rendering. Continuing with the example above, here is how you would [escape](/templates/escaping/) and output the "name" value in a template:
|
||||
Template data is available as locally scoped variables at the time of rendering. Continuing with the example above, here is how you would [escape]({{< relref "templates/escaping.md" >}}) and output the "name" value in a template:
|
||||
|
||||
~~~ php
|
||||
<p>Hello <?=$this->e($name)?></p>
|
||||
@@ -58,4 +57,4 @@ To assign data to ALL templates, simply omit the second parameter:
|
||||
$templates->addData(['name' => 'Jonathan']);
|
||||
~~~
|
||||
|
||||
Keep in mind that shared data is assigned to a template when it's first created, meaning any conflicting data assigned that's afterwards to a specific template will overwrite the shared data. This is generally desired behavior.
|
||||
Keep in mind that shared data is assigned to a template when it's first created, meaning any conflicting data assigned that's afterwards to a specific template will overwrite the shared data. This is generally desired behavior.
|
||||
+9
-10
@@ -1,11 +1,10 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/escaping/
|
||||
title: Escaping
|
||||
---
|
||||
|
||||
Escaping
|
||||
========
|
||||
+++
|
||||
title = "Escaping"
|
||||
linkTitle = "Templates Escaping"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 8
|
||||
+++
|
||||
|
||||
Escaping is a form of [data filtering](http://www.phptherightway.com/#data_filtering) which sanitizes unsafe, user supplied input prior to outputting it as HTML. Plates provides two shortcuts to the `htmlspecialchars()` function.
|
||||
|
||||
@@ -20,7 +19,7 @@ Escaping is a form of [data filtering](http://www.phptherightway.com/#data_filte
|
||||
|
||||
## Batch function calls
|
||||
|
||||
The escape functions also support [batch](/templates/functions/#batch-function-calls) function calls, which allow you to apply multiple functions, including native PHP functions, to a variable at one time.
|
||||
The escape functions also support [batch]({{< relref "templates/functions.md#batch-function-calls" >}}) function calls, which allow you to apply multiple functions, including native PHP functions, to a variable at one time.
|
||||
|
||||
~~~ php
|
||||
<p>Welcome <?=$this->e($name, 'strip_tags|strtoupper')?></p>
|
||||
@@ -47,4 +46,4 @@ Some [libraries](http://framework.zend.com/manual/2.1/en/modules/zend.escaper.es
|
||||
|
||||
Probably the biggest drawbacks to native PHP templates is the inability to auto-escape variables properly. Template languages like Twig and Smarty can identify "echoed" variables during a parsing stage and automatically escape them. This cannot be done in native PHP as the language does not offer overloading functionality for it's output functions (ie. `print` and `echo`).
|
||||
|
||||
Don't worry, escaping can still be done safely, it just means you are responsible for manually escaping each variable on output. Consider creating a snippet for one of the above, built-in escaping functions to make this process easier.
|
||||
Don't worry, escaping can still be done safely, it just means you are responsible for manually escaping each variable on output. Consider creating a snippet for one of the above, built-in escaping functions to make this process easier.
|
||||
+10
-11
@@ -1,11 +1,10 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/functions/
|
||||
title: Functions
|
||||
---
|
||||
|
||||
Functions
|
||||
=========
|
||||
+++
|
||||
title = "Functions"
|
||||
linkTitle = "Templates Functions"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 3
|
||||
+++
|
||||
|
||||
Template functions in Plates are accessed using the `$this` pseudo-variable.
|
||||
|
||||
@@ -16,7 +15,7 @@ Template functions in Plates are accessed using the `$this` pseudo-variable.
|
||||
|
||||
## Custom fuctions
|
||||
|
||||
In addition to the functions included with Plates, it's also possible to add [one-off functions](/engine/functions/), or even groups of functions, known as [extensions](/engine/extensions/).
|
||||
In addition to the functions included with Plates, it's also possible to add [one-off functions]({{< relref "engine/functions.md" >}}), or even groups of functions, known as [extensions]({{< relref "engine/extensions.md" >}}).
|
||||
|
||||
## Batch function calls
|
||||
|
||||
@@ -30,7 +29,7 @@ Sometimes you need to apply more than function to a variable in your templates.
|
||||
<p>Welcome <?=$this->batch($name, 'strip_tags|strtoupper|escape')?></p>
|
||||
~~~
|
||||
|
||||
The [escape](/templates/escaping/) functions also support batch function calls.
|
||||
The [escape]({{< relref "templates/escaping.md" >}}) functions also support batch function calls.
|
||||
|
||||
~~~ php
|
||||
<p>Welcome <?=$this->e($name, 'strip_tags|strtoupper')?></p>
|
||||
@@ -44,4 +43,4 @@ The batch functions works well for "piped" functions that accept one parameter,
|
||||
|
||||
<!-- Will output: jonathan -->
|
||||
<?=$this->batch('Jonathan', 'escape|strtoupper|strtolower')?>
|
||||
~~~
|
||||
~~~
|
||||
+15
-15
@@ -1,20 +1,19 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/inheritance/
|
||||
title: Inheritance
|
||||
---
|
||||
|
||||
Inheritance
|
||||
===========
|
||||
|
||||
By combining [layouts](/templates/layouts/) and [sections](/templates/sections/), Plates allows you to "build up" your pages using predefined sections. This is best understand using an example:
|
||||
+++
|
||||
title = "Inheritance"
|
||||
linkTitle = "Templates Inheritance"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 7
|
||||
+++
|
||||
|
||||
By combining [layouts]({{< relref "templates/layouts.md" >}}) and [sections]({{< relref "templates/sections.md" >}}), Plates allows you to "build up" your pages using predefined sections. This is best understand using an example:
|
||||
|
||||
## Inheritance example
|
||||
|
||||
The following example illustrates a pretty standard website. Start by creating a site template, which includes your header and footer as well as any predefined content [sections](/templates/sections/). Notice how Plates makes it possible to even set default section content, in the event that a page doesn't define it.
|
||||
The following example illustrates a pretty standard website. Start by creating a site template, which includes your header and footer as well as any predefined content [sections]({{< relref "templates/sections.md" >}}). Notice how Plates makes it possible to even set default section content, in the event that a page doesn't define it.
|
||||
|
||||
{{< code-filename template.php >}}
|
||||
|
||||
<div class="filename">template.php</div>
|
||||
~~~ php
|
||||
<html>
|
||||
<head>
|
||||
@@ -40,9 +39,10 @@ The following example illustrates a pretty standard website. Start by creating a
|
||||
</html>
|
||||
~~~
|
||||
|
||||
With the template defined, any page can now "implement" this [layout](/templates/layouts/). Notice how each section of content is defined between the `start()` and `end()` functions.
|
||||
With the template defined, any page can now "implement" this [layout]({{< relref "templates/layouts.md" >}}). Notice how each section of content is defined between the `start()` and `end()` functions.
|
||||
|
||||
{{< code-filename profile.php >}}
|
||||
|
||||
<div class="filename">profile.php</div>
|
||||
~~~ php
|
||||
<?php $this->layout('template', ['title' => 'User Profile']) ?>
|
||||
|
||||
@@ -60,4 +60,4 @@ With the template defined, any page can now "implement" this [layout](/templates
|
||||
<li><a href="/link">Example Link</a></li>
|
||||
</ul>
|
||||
<?php $this->stop() ?>
|
||||
~~~
|
||||
~~~
|
||||
+17
-15
@@ -1,11 +1,10 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/layouts/
|
||||
title: Layouts
|
||||
---
|
||||
|
||||
Layouts
|
||||
=======
|
||||
+++
|
||||
title = "Layouts"
|
||||
linkTitle = "Templates Layouts"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 5
|
||||
+++
|
||||
|
||||
The `layout()` function allows you to define a layout template that a template will implement. It's like having separate header and footer templates in one file.
|
||||
|
||||
@@ -20,7 +19,7 @@ The `layout()` function can be called anywhere in a template, since the layout t
|
||||
<p>Hello, <?=$this->e($name)?></p>
|
||||
~~~
|
||||
|
||||
This function also works with [folders](/engine/folders/):
|
||||
This function also works with [folders]({{< relref "engine/folders.md" >}}):
|
||||
|
||||
~~~ php
|
||||
<?php $this->layout('shared::template') ?>
|
||||
@@ -36,7 +35,7 @@ To assign data (variables) to a layout template, pass them as an array to the `l
|
||||
|
||||
## Accessing the content
|
||||
|
||||
To access the rendered template content within the layout, use the `section()` function, passing `'content'` as the section name. This will return all outputted content from the template that hasn't been defined in a [section](/templates/sections/).
|
||||
To access the rendered template content within the layout, use the `section()` function, passing `'content'` as the section name. This will return all outputted content from the template that hasn't been defined in a [section]({{< relref "templates/sections.md" >}}).
|
||||
|
||||
~~~ php
|
||||
<html>
|
||||
@@ -57,7 +56,8 @@ Plates allows stacking of layouts, allowing even further simplification and orga
|
||||
|
||||
### The main site layout
|
||||
|
||||
<div class="filename">template.php</div>
|
||||
{{< code-filename template.php >}}
|
||||
|
||||
~~~ php
|
||||
<html>
|
||||
<head>
|
||||
@@ -73,9 +73,10 @@ Plates allows stacking of layouts, allowing even further simplification and orga
|
||||
|
||||
### The blog layout
|
||||
|
||||
<div class="filename">blog.php</div>
|
||||
{{< code-filename blog.php >}}
|
||||
|
||||
~~~ php
|
||||
<?php $this->layout('template') ?>
|
||||
<?php $this->layout('template', ['title' => $title]) ?>
|
||||
|
||||
<h1>The Blog</h1>
|
||||
|
||||
@@ -91,7 +92,8 @@ Plates allows stacking of layouts, allowing even further simplification and orga
|
||||
|
||||
### A blog article
|
||||
|
||||
<div class="filename">blog-article.php</div>
|
||||
{{< code-filename blog-article.php >}}
|
||||
|
||||
~~~ php
|
||||
<?php $this->layout('blog', ['title' => $article->title]) ?>
|
||||
|
||||
@@ -99,4 +101,4 @@ Plates allows stacking of layouts, allowing even further simplification and orga
|
||||
<article>
|
||||
<?=$this->e($article->content)?>
|
||||
</article>
|
||||
~~~
|
||||
~~~
|
||||
+9
-10
@@ -1,11 +1,10 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/nesting/
|
||||
title: Nesting
|
||||
---
|
||||
|
||||
Nesting
|
||||
=======
|
||||
+++
|
||||
title = "Nesting"
|
||||
linkTitle = "Templates Nesting"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 4
|
||||
+++
|
||||
|
||||
Including another template into the current template is done using the `insert()` function:
|
||||
|
||||
@@ -17,7 +16,7 @@ Including another template into the current template is done using the `insert()
|
||||
<?php $this->insert('partials/footer') ?>
|
||||
~~~
|
||||
|
||||
The `insert()` function also works with [folders](/engine/folders/):
|
||||
The `insert()` function also works with [folders]({{< relref "engine/folders.md" >}}):
|
||||
|
||||
~~~ php
|
||||
<?php $this->insert('partials::header') ?>
|
||||
@@ -41,4 +40,4 @@ To assign data (variables) to a nested template, pass them as an array to the `i
|
||||
<p>Your content.</p>
|
||||
|
||||
<?php $this->insert('partials/footer') ?>
|
||||
~~~
|
||||
~~~
|
||||
+10
-11
@@ -1,13 +1,12 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/
|
||||
title: Templates
|
||||
---
|
||||
+++
|
||||
title = "Overview"
|
||||
linkTitle = "Templates Overview"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 1
|
||||
+++
|
||||
|
||||
Templates
|
||||
=========
|
||||
|
||||
Plates templates are very simple PHP objects. Generally you'll want to create these using the two factory methods, `make()` and `render()`, in the [engine](/engine/). For example:
|
||||
Plates templates are very simple PHP objects. Generally you'll want to create these using the two factory methods, `make()` and `render()`, in the [engine]({{< relref "engine/overview.md" >}}). For example:
|
||||
|
||||
~~~ php
|
||||
// Create new Plates instance
|
||||
@@ -20,11 +19,11 @@ echo $templates->render('partials/header');
|
||||
echo $templates->render('profile', ['name' => 'Jonathan']);
|
||||
~~~
|
||||
|
||||
For more information about how Plates is designed to be easily added to your application, see the section on [dependency injection](/engine/#dependency-injection).
|
||||
For more information about how Plates is designed to be easily added to your application, see the section on [dependency injection]({{< relref "engine/overview.md#dependency-injection" >}}).
|
||||
|
||||
## Manually creating templates
|
||||
|
||||
It's also possible to create templates manually. The only dependency they require is an instance of the [engine](/engine/) object. For example:
|
||||
It's also possible to create templates manually. The only dependency they require is an instance of the [engine]({{< relref "engine/overview.md" >}}) object. For example:
|
||||
|
||||
~~~ php
|
||||
// Create new Plates instance
|
||||
+14
-11
@@ -1,13 +1,12 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/sections/
|
||||
title: Sections
|
||||
---
|
||||
+++
|
||||
title = "Sections"
|
||||
linkTitle = "Templates Sections"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 6
|
||||
+++
|
||||
|
||||
Sections
|
||||
========
|
||||
|
||||
The `start()` and `stop` functions allow you to build sections (or blocks) of content within your template, and instead of them being rendered directly, they are saved for use elsewhere. For example, in your [layout](/templates/layouts/) template.
|
||||
The `start()` and `stop` functions allow you to build sections (or blocks) of content within your template, and instead of them being rendered directly, they are saved for use elsewhere. For example, in your [layout]({{< relref "templates/layouts.md" >}}) template.
|
||||
|
||||
## Creating sections
|
||||
|
||||
@@ -24,12 +23,16 @@ You define the name of the section with the `start()` function. To end a section
|
||||
|
||||
## Stacking section content
|
||||
|
||||
By default, when you render a section its content will overwrite any existing content for that section. However, it's possible to append (or stack) the content instead using the `push()` method. This can be useful for specifying any JavaScript libraries required by your child views.
|
||||
By default, when you render a section its content will overwrite any existing content for that section. However, it's possible to append/prepend (or stack) the content instead using the `push()` or `unshift()` method respectively. This can be useful for specifying any JavaScript libraries or CSS files required by your child views.
|
||||
|
||||
~~~ php
|
||||
<?php $this->push('scripts') ?>
|
||||
<script src="example.js"></script>
|
||||
<?php $this->end() ?>
|
||||
|
||||
<?php $this->unshift('styles') ?>
|
||||
<link rel="stylesheet" href="example.css" />
|
||||
<?php $this->end() ?>
|
||||
~~~
|
||||
|
||||
<p class="message-notice">The <code>end()</code> function is simply an alias of <code>stop()</code>. These functions can be used interchangeably.</p>
|
||||
@@ -50,7 +53,7 @@ In situations where a page doesn't implement a particular section, it's helpful
|
||||
|
||||
### Defining it inline
|
||||
|
||||
If the default content can be defined in a single line of code, it's best to simply pass it as the second parameter of the `content()` function.
|
||||
If the default content can be defined in a single line of code, it's best to simply pass it as the second parameter of the `section()` function.
|
||||
|
||||
~~~ php
|
||||
<div id="sidebar">
|
||||
vendor/league/plates/docs/templates/syntax.md → vendor/league/plates/doc/content/templates/syntax.md
Vendored
+8
-9
@@ -1,18 +1,17 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: templates/syntax/
|
||||
title: Syntax
|
||||
---
|
||||
|
||||
Syntax
|
||||
======
|
||||
+++
|
||||
title = "Syntax"
|
||||
linkTitle = "Templates Syntax"
|
||||
[menu.main]
|
||||
parent = "templates"
|
||||
weight = 9
|
||||
+++
|
||||
|
||||
While the actual syntax you use in your templates is entirely your choice (it's just PHP after all), we suggest the following syntax guidelines to help keep templates clean and legible.
|
||||
|
||||
## Guidelines
|
||||
|
||||
- Always use HTML with inline PHP. Never use blocks of PHP.
|
||||
- Always escape potentially dangerous variables prior to outputting using the built-in escape functions. More on escaping [here](/templates/escaping/).
|
||||
- Always escape potentially dangerous variables prior to outputting using the built-in escape functions. More on escaping [here]({{< relref "templates/escaping.md" >}}).
|
||||
- Always use the short echo syntax (`<?=`) when outputting variables. For all other inline PHP code, use full the `<?php` tag. Do not use [short tags](http://us3.php.net/manual/en/ini.core.php#ini.short-open-tag).
|
||||
- Always use the [alternative syntax for control structures](http://php.net/manual/en/control-structures.alternative-syntax.php), which are designed to make templates more legible.
|
||||
- Never use PHP curly brackets.
|
||||
@@ -0,0 +1,114 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ .Site.Language.Lang }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
{{ if .IsHome }}
|
||||
<title>{{ .Site.Title }} - {{ .Site.Params.tagline }}</title>
|
||||
{{ else }}
|
||||
<title>{{ partial "title" . }} | {{ .Site.Title -}}</title>
|
||||
{{ end }}
|
||||
{{ if .Site.Params.description }}
|
||||
<meta name="description" content="{{ .Site.Params.description }}">
|
||||
{{ end }}
|
||||
{{ if .Site.Params.Images.favicon }}
|
||||
<link rel="icon" type="image/x-icon" href="{{ .Site.Params.Images.favicon | relURL }}" />
|
||||
{{ else }}
|
||||
<link rel="icon" type="image/x-icon" href="https://theme.thephpleague.com/img/favicon.ico" />
|
||||
{{ end }}
|
||||
{{ if .Site.Params.Images.appleTouch }}
|
||||
<link rel="apple-touch-icon-precomposed" href="{{ .Site.Params.Images.appleTouch | relURL }}">
|
||||
{{ else }}
|
||||
<link rel="apple-touch-icon-precomposed" href="https://theme.thephpleague.com/img/apple-touch-icon-precomposed.png">
|
||||
{{ end }}
|
||||
<link rel="stylesheet" href="https://theme.thephpleague.com/css/all.css">
|
||||
<link rel="stylesheet" href="{{ "css/custom.css" | relURL }}">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a href="https://github.com/thephpleague/plates" class="github">
|
||||
<img src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png">
|
||||
</a>
|
||||
|
||||
<section class="all_packages">
|
||||
<a href="https://thephpleague.com/">
|
||||
<img src="https://theme.thephpleague.com/img/loep_logo.png" width="195" height="200" alt="The League of Extraordinary Packages">
|
||||
</a>
|
||||
<h2>Our Packages:</h2>
|
||||
<ul>
|
||||
<!-- Loaded via JavaScript -->
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<header>
|
||||
<a class="logo" href="/">
|
||||
{{ if .Site.Params.Images.logo }}
|
||||
<span class="icon">
|
||||
<img src="{{ .Site.Params.Images.logo | relURL }}" width="50" height="40" alt="{{ .Site.Title }} - {{ .Site.Params.tagline }}">
|
||||
</span>
|
||||
{{ end }}
|
||||
<span class="name">{{ .Site.Title }}</span>
|
||||
<span class="tagline">{{ .Site.Params.tagline }}</span>
|
||||
</a>
|
||||
<a href="https://thephpleague.com/" class="league">
|
||||
Presented by The League of Extraordinary Packages
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<input type="checkbox" id="menu">
|
||||
<label for="menu" onclick>
|
||||
<div class="closed">☰ Menu</div>
|
||||
<div class="open">☰ Hide Menu</div>
|
||||
</label>
|
||||
|
||||
<main>
|
||||
<menu>
|
||||
{{ $currentPage := . }}
|
||||
{{ range .Site.Menus.main }}
|
||||
<h2>{{ .Name }}</h2>
|
||||
<ul>
|
||||
{{ range .Children }}
|
||||
<li class="{{ if $currentPage.IsMenuCurrent "main" . }}selected{{ end }}">
|
||||
<a href="{{ .URL }}">{{ .Page.Title }}</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</menu>
|
||||
<article>
|
||||
{{ template "main" . }}
|
||||
</article>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<span>© Copyright <a href="https://thephpleague.com">The League of Extraordinary Packages</a>.</span>
|
||||
<span>Site design by <a href="https://reinink.ca">Jonathan Reinink</a>.</span>
|
||||
</footer>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://theme.thephpleague.com/js/scripts.js"></script>
|
||||
<script src="https://theme.thephpleague.com/js/prism.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
|
||||
<script>
|
||||
$('select.select2').select2().on('change', function(e) {
|
||||
var pathParts = window.location.pathname.split("/");
|
||||
pathParts[1] = e.currentTarget.value;
|
||||
window.location.href = pathParts.join("/");
|
||||
});
|
||||
</script>
|
||||
|
||||
{{ if .Site.GoogleAnalytics }}
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
|
||||
ga('create','{{ .Site.GoogleAnalytics }}');ga('send','pageview');
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,4 @@
|
||||
{{ define "main" }}
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,4 @@
|
||||
{{ define "main" }}
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,11 @@
|
||||
{{ $title := "" }}
|
||||
|
||||
{{ if .Title }}
|
||||
{{ $title = .Title }}
|
||||
{{ else if and .IsSection .File }}
|
||||
{{ $title = path.Base .File.Dir | humanize | title }}
|
||||
{{ else if and .IsPage .File }}
|
||||
{{ $title = .File.BaseFileName | humanize | title }}
|
||||
{{ end }}
|
||||
|
||||
{{ return $title }}
|
||||
@@ -0,0 +1 @@
|
||||
<div class="filename">{{ index .Params 0 }}</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
{{/* ref: https://anaulin.org/blog/hugo-raw-html-shortcode/ */}}
|
||||
<!-- raw html -->
|
||||
{{.Inner}}
|
||||
+11
-4
@@ -1,6 +1,3 @@
|
||||
---
|
||||
---
|
||||
|
||||
.github {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
@@ -13,4 +10,14 @@
|
||||
.github {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*:focus {
|
||||
outline: none;
|
||||
}
|
||||
.select2-container {
|
||||
font-family: "Museo 300";
|
||||
}
|
||||
.version-select {
|
||||
margin: 8px 25px 0px 45px;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Vendored
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
-8
@@ -1,8 +0,0 @@
|
||||
# Path to project specific favicon.ico, leave blank to use default
|
||||
favicon: /favicon.ico
|
||||
|
||||
# Path to project specific apple-touch-icon-precomposed.png, leave blank to use default
|
||||
apple_touch: /apple-touch-icon-precomposed.png
|
||||
|
||||
# Path to project logo
|
||||
logo: /logo.png
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
Getting Started:
|
||||
Introduction: '/'
|
||||
Simple example: '/simple-example/'
|
||||
Installation: '/installation/'
|
||||
Changelog: '/changelog/'
|
||||
The Engine:
|
||||
Overview: '/engine/'
|
||||
File extensions: '/engine/file-extensions/'
|
||||
Folders: '/engine/folders/'
|
||||
Functions: '/engine/functions/'
|
||||
Extensions: '/engine/extensions/'
|
||||
Templates:
|
||||
Overview: '/templates/'
|
||||
Data: '/templates/data/'
|
||||
Functions: '/templates/functions/'
|
||||
Nesting: '/templates/nesting/'
|
||||
Layouts: '/templates/layouts/'
|
||||
Sections: '/templates/sections/'
|
||||
Inheritance: '/templates/inheritance/'
|
||||
Escaping: '/templates/escaping/'
|
||||
Syntax: '/templates/syntax/'
|
||||
Extensions:
|
||||
Asset: '/extensions/asset/'
|
||||
URI: '/extensions/uri/'
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
title: Plates
|
||||
tagline: Native PHP Templates
|
||||
description: 'Plates is a Twig inspired, native PHP template system that brings modern template language functionality to native PHP templates.'
|
||||
google_analytics_tracking_id: UA-46050814-2
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
{% if page.url == '/' %}
|
||||
<title>{{ site.data.project.title }} - {{ site.data.project.tagline }}</title>
|
||||
{% else %}
|
||||
<title>{{ page.title }} - {{ site.data.project.title }}</title>
|
||||
{% endif %}
|
||||
{% if site.data.project.description %}
|
||||
<meta name="description" content="{{ site.data.project.description }}">
|
||||
{% endif %}
|
||||
{% if site.github.url %}
|
||||
<base href="{{ site.github.url }}">
|
||||
{% endif %}
|
||||
{% if site.data.images.favicon %}
|
||||
<link rel="icon" type="image/x-icon" href="{{ site.data.images.favicon }}" />
|
||||
{% else %}
|
||||
<link rel="icon" type="image/x-icon" href="http://theme.thephpleague.com/img/favicon.ico" />
|
||||
{% endif %}
|
||||
{% if site.data.images.apple_touch %}
|
||||
<link rel="apple-touch-icon-precomposed" href="{{ site.data.images.apple_touch }}">
|
||||
{% else %}
|
||||
<link rel="apple-touch-icon-precomposed" href="http://theme.thephpleague.com/img/apple-touch-icon-precomposed.png">
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="http://theme.thephpleague.com/css/all.css">
|
||||
<link rel="stylesheet" href="/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a href="https://github.com/thephpleague/plates" class="github">
|
||||
<img src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png">
|
||||
</a>
|
||||
|
||||
<section class="all_packages">
|
||||
<a href="http://thephpleague.com/">
|
||||
<img src="http://theme.thephpleague.com/img/loep_logo.png" width="195" height="200" alt="The League of Extraordinary Packages">
|
||||
</a>
|
||||
<h2>Our Packages:</h2>
|
||||
<ul>
|
||||
<!-- Loaded via JavaScript -->
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<header>
|
||||
<a class="logo" href="/">
|
||||
{% if site.data.images.logo %}
|
||||
<span class="icon">
|
||||
<img src="{{ site.data.images.logo }}" width="50" height="40" alt="{{ site.data.project.title }} - {{ site.data.project.tagline }}">
|
||||
</span>
|
||||
{% endif %}
|
||||
<span class="name">{{ site.data.project.title }}</span>
|
||||
<span class="tagline">{{ site.data.project.tagline }}</span>
|
||||
</a>
|
||||
<a href="http://thephpleague.com/" class="league">
|
||||
Presented by The League of Extraordinary Packages
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<input type="checkbox" id="menu">
|
||||
<label for="menu" onclick>
|
||||
<div class="closed">☰ Menu</div>
|
||||
<div class="open">☰ Hide Menu</div>
|
||||
</label>
|
||||
|
||||
<main>
|
||||
<menu>
|
||||
{% for section in site.data.menu %}
|
||||
<h2>{{ section[0] }}</h2>
|
||||
<ul>
|
||||
{% for link in section[1] %}
|
||||
<li {% if page.url == link[1] %}class="selected"{% endif %}>
|
||||
<a href="{{ link[1] }}">{{ link[0] }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
</menu>
|
||||
<article>
|
||||
{{ content }}
|
||||
</article>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<span>© Copyright <a href="http://thephpleague.com">The League of Extraordinary Packages</a>.</span>
|
||||
<span>Site design by <a href="http://reinink.ca">Jonathan Reinink</a>.</span>
|
||||
</footer>
|
||||
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="http://theme.thephpleague.com/js/scripts.js"></script>
|
||||
<script src="http://theme.thephpleague.com/js/prism.js"></script>
|
||||
|
||||
{% if site.data.project.google_analytics_tracking_id %}
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
|
||||
ga('create','{{ site.data.project.google_analytics_tracking_id }}');ga('send','pageview');
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
permalink: changelog/
|
||||
title: Changelog
|
||||
---
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
{% for release in site.github.releases %}
|
||||
## [{{ release.name }}]({{ release.html_url }}) - {{ release.published_at | date: "%Y-%m-%d" }}
|
||||
{{ release.body | markdownify }}
|
||||
{% endfor %}
|
||||
+29
-13
@@ -1,20 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit colors="true" bootstrap="vendor/autoload.php">
|
||||
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.4/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
verbose="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
stopOnFailure="false"
|
||||
executionOrder="random"
|
||||
resolveDependencies="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="all">
|
||||
<directory suffix="Test.php">tests/</directory>
|
||||
<testsuite name="Plates tests">
|
||||
<directory>./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<coverage>
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
|
||||
<logging>
|
||||
<log type="tap" target="build/report.tap"/>
|
||||
<log type="junit" target="build/report.junit.xml"/>
|
||||
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
|
||||
<log type="coverage-text" target="build/coverage.txt"/>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
<junit outputFile="build/report.junit.xml"/>
|
||||
<testdoxHtml outputFile="build/coverage"/>
|
||||
<testdoxText outputFile="build/coverage.txt"/>
|
||||
<testdoxXml outputFile="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class Asset implements ExtensionInterface
|
||||
|
||||
if ($pathInfo['dirname'] === '.') {
|
||||
$directory = '';
|
||||
} elseif ($pathInfo['dirname'] === '/') {
|
||||
} elseif ($pathInfo['dirname'] === DIRECTORY_SEPARATOR) {
|
||||
$directory = '/';
|
||||
} else {
|
||||
$directory = $pathInfo['dirname'] . '/';
|
||||
|
||||
+8
-4
@@ -161,13 +161,17 @@ class Name
|
||||
public function getPath()
|
||||
{
|
||||
if (is_null($this->folder)) {
|
||||
return $this->getDefaultDirectory() . DIRECTORY_SEPARATOR . $this->file;
|
||||
return "{$this->getDefaultDirectory()}/{$this->file}";
|
||||
}
|
||||
|
||||
$path = $this->folder->getPath() . DIRECTORY_SEPARATOR . $this->file;
|
||||
$path = "{$this->folder->getPath()}/{$this->file}";
|
||||
|
||||
if (!is_file($path) and $this->folder->getFallback() and is_file($this->getDefaultDirectory() . DIRECTORY_SEPARATOR . $this->file)) {
|
||||
$path = $this->getDefaultDirectory() . DIRECTORY_SEPARATOR . $this->file;
|
||||
if (
|
||||
!is_file($path)
|
||||
&& $this->folder->getFallback()
|
||||
&& is_file("{$this->getDefaultDirectory()}/{$this->file}")
|
||||
) {
|
||||
$path = "{$this->getDefaultDirectory()}/{$this->file}";
|
||||
}
|
||||
|
||||
return $path;
|
||||
|
||||
+42
-4
@@ -12,6 +12,16 @@ use Throwable;
|
||||
*/
|
||||
class Template
|
||||
{
|
||||
const SECTION_MODE_REWRITE = 1;
|
||||
const SECTION_MODE_PREPEND = 2;
|
||||
const SECTION_MODE_APPEND = 3;
|
||||
|
||||
/**
|
||||
* Set section content mode: rewrite/append/prepend
|
||||
* @var int
|
||||
*/
|
||||
protected $sectionMode = self::SECTION_MODE_REWRITE;
|
||||
|
||||
/**
|
||||
* Instance of the template engine.
|
||||
* @var Engine
|
||||
@@ -44,6 +54,7 @@ class Template
|
||||
|
||||
/**
|
||||
* Whether the section should be appended or not.
|
||||
* @deprecated stayed for backward compatibility, use $sectionMode instead
|
||||
* @var boolean
|
||||
*/
|
||||
protected $appendSection;
|
||||
@@ -211,14 +222,26 @@ class Template
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new append section block.
|
||||
* Start a new section block in APPEND mode.
|
||||
* @param string $name
|
||||
* @return null
|
||||
*/
|
||||
public function push($name)
|
||||
{
|
||||
$this->appendSection = true;
|
||||
$this->appendSection = true; /* for backward compatibility */
|
||||
$this->sectionMode = self::SECTION_MODE_APPEND;
|
||||
$this->start($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new section block in PREPEND mode.
|
||||
* @param string $name
|
||||
* @return null
|
||||
*/
|
||||
public function unshift($name)
|
||||
{
|
||||
$this->appendSection = false; /* for backward compatibility */
|
||||
$this->sectionMode = self::SECTION_MODE_PREPEND;
|
||||
$this->start($name);
|
||||
}
|
||||
|
||||
@@ -238,9 +261,24 @@ class Template
|
||||
$this->sections[$this->sectionName] = '';
|
||||
}
|
||||
|
||||
$this->sections[$this->sectionName] = $this->appendSection ? $this->sections[$this->sectionName] . ob_get_clean() : ob_get_clean();
|
||||
switch ($this->sectionMode) {
|
||||
|
||||
case self::SECTION_MODE_REWRITE:
|
||||
$this->sections[$this->sectionName] = ob_get_clean();
|
||||
break;
|
||||
|
||||
case self::SECTION_MODE_APPEND:
|
||||
$this->sections[$this->sectionName] .= ob_get_clean();
|
||||
break;
|
||||
|
||||
case self::SECTION_MODE_PREPEND:
|
||||
$this->sections[$this->sectionName] = ob_get_clean().$this->sections[$this->sectionName];
|
||||
break;
|
||||
|
||||
}
|
||||
$this->sectionName = null;
|
||||
$this->appendSection = false;
|
||||
$this->sectionMode = self::SECTION_MODE_REWRITE;
|
||||
$this->appendSection = false; /* for backward compatibility */
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user