2017 © Pedro Peláez
 

library component-macro

image

webchemistry/component-macro

  • Thursday, June 8, 2017
  • by Antik
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4,630 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Component-Macro

Replacement of include, import from nette with more beautiful and shorter version., (*1)

Build Status, (*2)

Installation

    WebChemistry\Macros\ComponentMacro::install($latte->getCompiler(), __DIR__ . '/component-dir');

Usage single file

    <Template n:component />

~ Same in nette:, (*3)

    {include __DIR__ . '/component-dir/template.latte'}
````
Renders content from component-dir/template.latte

## Usage single file, multiple blocks

```html
    <TemplateFirst block n:component /> <!-- Renders block 'first' -->
    <TemplateSecond block n:component="key => value" /> <!-- Renders block 'second' -->

Same in nette:, (*4)

{import __DIR__ . '/component-dir/template.latte'}

{include #first}
{include #second key => value}

template.latte, (*5)

{define first}
    ...
{/define}

{define second}
    {$key}
    ...
{/define}

Usage file from other directory

    <TemplateFirst n:component />

Same in nette:, (*6)

{include __DIR__ . '/component-dir/template/first.latte'}

template/first.latte:, (*7)

...

Custom parameters

    <Template n:component="foo => bar" />
````

Same in nette:
```html
    {include __DIR__ . '/component-dir/template.latte' foo => bar}

template.latte, (*8)

    {$foo}

Content

    <Template n:component>
        Content with dynamic parameter or with macros <Template n:component />
    </Template>

Same in nette:, (*9)

{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, (*10)

{!$_content}

Modifiers

    <Template modifiers="stripHtml|truncate:500" n:component>
            Content with dynamic parameter or with macros <Template n:component />
    </Template>

Same in nette:, (*11)

{include __DIR__ . '/component-dir/template.latte' _content => $foo|stripHtml|truncate:500}

The Versions

08/06 2017

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

08/06 2017

2.0

2.0.0.0

  Sources   Download

The Requires

 

The Development Requires

07/08 2016

1.0.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires