Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webchemistry/component-macro
Replacement of include, import from nette with more beautiful and shorter version.
https://github.com/webchemistry/component-macro
Last synced: about 1 month ago
JSON representation
Replacement of include, import from nette with more beautiful and shorter version.
- Host: GitHub
- URL: https://github.com/webchemistry/component-macro
- Owner: WebChemistry
- Created: 2016-06-15T10:13:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-08T13:57:19.000Z (over 7 years ago)
- Last Synced: 2024-11-17T20:53:51.236Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Component-Macro
Replacement of include, import from nette with more beautiful and shorter version.[![Build Status](https://travis-ci.org/WebChemistry/component-macro.svg?branch=master)](https://travis-ci.org/WebChemistry/component-macro)
## Installation
```php
WebChemistry\Macros\ComponentMacro::install($latte->getCompiler(), __DIR__ . '/component-dir');
```## Usage single file
```html
```
~
Same in nette:
```html
{include __DIR__ . '/component-dir/template.latte'}
````
Renders content from component-dir/template.latte## Usage single file, multiple blocks
```html
```Same in nette:
```html
{import __DIR__ . '/component-dir/template.latte'}{include #first}
{include #second key => value}
```template.latte
```html
{define first}
...
{/define}{define second}
{$key}
...
{/define}
```## Usage file from other directory
```html
```Same in nette:
```html
{include __DIR__ . '/component-dir/template/first.latte'}
```template/first.latte:
```html
...
```## Custom parameters
```html
````Same in nette:
```html
{include __DIR__ . '/component-dir/template.latte' foo => bar}
```template.latte
```html
{$foo}
```## Content
```html
Content with dynamic parameter or with macros
```Same in nette:
```html
{capture $foo}
Content with dynamic parameter or with macros {include __DIR__ . '/component-dir/template.latte'}
{/capture}
{include __DIR__ . '/component-dir/template.latte' _content => $foo}
```template.latte
```html
{!$_content}
```## Modifiers
```html
Content with dynamic parameter or with macros
```Same in nette:
```html
{include __DIR__ . '/component-dir/template.latte' _content => $foo|stripHtml|truncate:500}
```