Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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}
```