2017 © Pedro Peláez
 

library platesattributes

[Plates Extension] Transform an array in html tag attributes.

image

ropendev/platesattributes

[Plates Extension] Transform an array in html tag attributes.

  • Tuesday, January 13, 2015
  • by RobinD
  • Repository
  • 1 Watchers
  • 2 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 8 % Grown

The README.md

This package is not maintened anymore (but still works) : Use https://github.com/PiedWeb/RenderHtmlAttribute, (*1)

Plates Extension : Render html tag attributes

Quality Score SensioLabsInsight Build Status, (*2)

This package is an extension for the template engine Plates., (*3)

Two features for the same goal Manipulate html tag attributes via PHP array : * $this->attr(array $attributes) transform an array in html tag attributes * $this->mergeAttr(array $arr1, array $arr2, [array $arr3, ...]) merge multiple array without loosing values (Eg. : ['class' => 'main'] + ['class' => 'content'] = ['class' => 'main content']), (*4)

Table of contents

Usage

/* Template Init */
$templateEngine = new \League\Plates\Engine('app/views');

/* Load this extension */
$templateEngine->loadExtension(new \rOpenDev\PlatesExtension\Attributes());

$this->render('test', ['attributes' => ['class' => 'content']]);

In your app/views/test.php template file:, (*5)

<?php
$defaultAttributes = ['class' => 'main'];
$attributes        = isset($attributes) ? $this->mergeAttr($defaultAttributes, $attributes) : $defaultAttributes;
?>
<div<?=$this->attr($attributes)?>>Hello World !</div>

Will render:, (*6)

<div class="main content">Hello World !</div>

Installation

composer require ropendev/platesattributes

Requirements

Stand alone extension., (*7)

See composer.json file., (*8)

Contributing

See CONTRIBUTING.md file., (*9)

Contributors

License

MIT (see the LICENSE file for details), (*10)

The Versions

13/01 2015

dev-master

9999999-dev https://github.com/RobinDev/platesAttributes

[Plates Extension] Transform an array in html tag attributes.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

templating template view plates

13/01 2015

1.0.1

1.0.1.0 https://github.com/RobinDev/platesAttributes

[Plates Extension] Transform an array in html tag attributes.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

templating template view plates

15/12 2014

1.0.0

1.0.0.0 https://github.com/RobinDev/platesAttributes

[Plates Extension] Transform an array in html tag attributes.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

templating template view plates