2017 © Pedro Peláez
 

library html-element

Zend Framework view helper plugin to use html tags like objects and to render them.

image

sandrokeil/html-element

Zend Framework view helper plugin to use html tags like objects and to render them.

  • Friday, August 4, 2017
  • by sandrokeil
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5,493 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

HtmlElement view helper for Zend Framework

You want HTML tags as objects?, (*1)

You want surefire generated HTML tags and HTML attributes?, (*2)

You want to generate HTML tags on the fly?, (*3)

This module comes to the rescue!, (*4)

Build Status Scrutinizer Code Quality Coverage Status HHVM Status SensioLabsInsight Latest Stable Version Dependency Status Total Downloads License, (*5)

Zend Framework view helper plugin for generating HTML tags. Use HTML tags as objects and manipulate HTML attributes and values., (*6)

  • Well tested. Besides unit tests and continuous integration/inspection this solution is also ready for production use.
  • Great foundations. Based on Zend Framework and interop-config
  • Every change is tracked. Want to know whats new? Take a look at CHANGELOG.md
  • Listen to your ideas. Have a great idea? Bring your tested pull request or open a new issue. See CONTRIBUTING.md

Installation

Installation of this module uses Composer. For Composer documentation, please refer to getcomposer.org., (*7)

Put the following into your composer.json, (*8)

{
    "require": {
        "sandrokeil/html-element": "^2.0"
    }
}

Please register the HtmlElement view helper to your Zend\View plugin manager. You can use the Sake\HtmlElement\Service\HtmlElementFactory factory if you install interop-config., (*9)

return [
   'view_helpers' => [
        'factories' => [
            \Sake\HtmlElement\View\Helper\HtmlElement::class => \Sake\HtmlElement\Service\HtmlElementFactory::class,
        ],
    ],
];

Documentation

The usage is easy. Here is an example how to use the view helper, (*10)

<?php

// assume we are in a template
echo $this->html('div', 'my content', array('id' => 'content', 'class' => 'box shadow'));

// or
$div = $this->html('div');
echo $div->setText('my content')
    ->setAttributes(array('id' => 'content', 'class' => 'box shadow'));

// to render HTML you can use
echo $div->enableHtml(true)
    ->setText(
        $this->html('p')->setText('Hello World!')->appendClass('welcome');
    );

// or
echo $this->html(
    'div',
    $this->html('p')->setText('Hello World!')->appendClass('welcome'),
    array('id' => 'content', 'class' => 'box shadow'),
    true
);

Performance tweaks

The default behaviour of HtmlElement is maximum security. But if you have thousands of HTML tags it could be slow. If your HTML attributes are not from user input, you can disable escaping of HTML attributes to increase performance. You can also disable escaping of text to unleash the beast. ;-) This is simply done by adding the following lines to your config file, but keep security in mind., (*11)

<?php

return array(
    'sake_htmlelement' => array(
        'view_helper' => array(
            'default' => array(
                'escapeHtmlAttribute' => false,
                'escapeText' => false,
            ),
        ),
    ),
    // other module config stuff
);

The Versions

04/08 2017

dev-master

9999999-dev https://github.com/sandrokeil/HtmlElement

Zend Framework view helper plugin to use html tags like objects and to render them.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 html zend framework view helper zf3 view html element html objects

04/08 2017

2.0.0

2.0.0.0 https://github.com/sandrokeil/HtmlElement

Zend Framework view helper plugin to use html tags like objects and to render them.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 html zend framework view helper zf3 view html element html objects

04/08 2017

dev-develop

dev-develop https://github.com/sandrokeil/HtmlElement

Zend Framework view helper plugin to use html tags like objects and to render them.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 html zend framework view helper zf3 view html element html objects

04/08 2017

dev-php7

dev-php7 https://github.com/sandrokeil/HtmlElement

Zend Framework view helper plugin to use html tags like objects and to render them.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 html zend framework view helper zf3 view html element html objects

10/06 2014

1.0.0

1.0.0.0 https://github.com/sandrokeil/HtmlElement

Zend Framework 2 view helper plugin to use html tags like objects and to render them.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

zf2 html zend framework view helper view html element html objects