Skip to content

stevebauman/html

 
 

Repository files navigation

HTML Component for Orchestra Platform

HTML Component extends the functionality of Illuminate\Html with the extra functionality to including a chainable Form and Table builder. These set of functionality are the backbone in allowing extensions in Orchestra Platform to attach action to any existing form or table.

Latest Stable Version Total Downloads MIT License Build Status Coverage Status Scrutinizer Quality Score

Table of Content

Version Compatibility

Laravel HTML
4.0.x 2.0.x
4.1.x 2.1.x
4.2.x 2.2.x
5.0.x 3.0.x
5.1.x 3.1.x
5.2.x 3.2.x@dev

Installation

To install through composer, simply put the following in your composer.json file:

{
	"require": {
		"orchestra/html": "~3.0"
	}
}

And then run composer install from the terminal.

Quick Installation

Above installation can also be simplify by using the following command:

composer require "orchestra/html=~3.0"

Configuration

Next add the service provider in config/app.php.

'providers' => [

    // ...

    Orchestra\Html\HtmlServiceProvider::class,
],

Aliases

You might want to add the following to class aliases in config/app.php:

'aliases' => [

    // ...

    'Form' => Orchestra\Support\Facades\Form::class,
    'HTML' => Orchestra\Support\Facades\HTML::class,
    'Table' => Orchestra\Support\Facades\Table::class,
],

Usage

Orchestra\Html\HtmlBuilder is a small improvement from Illuminate\Html\HtmlBuilder.

Advise to use this only when manipulating HTML outside of view, otherwise it's better (and faster) to use html.

Create HTML

Create a HTML tag from within your libraries/extension using following code:

return HTML::create('p', 'Some awesome information');

// will return <p>Some awesome information</p>

You can customize the HTML attibutes by adding third parameter.

return HTML::create('p', 'Another awesomeness', ['id' => 'foo']);

// will return <p id="foo">Another awesomeness</p>

Raw HTML Entities

Mark a string to be excluded from being escaped.

return HTML::link('foo', HTML::raw('<img src="foo.jpg">'));

// will return <a href="foo"><img src="foo.jpg"></a>

Decorate HTML

Decorate method allow developer to define HTML attributes collection as HTML::attributes method, with the addition of including default attributes array as second parameter.

return HTML::decorate(['class' => 'foo'], ['id' => 'foo', 'class' => 'span5']);

// will return array('class' => 'foo span5', 'id' => 'foo');

It also support replacement of default attributes if such requirement is needed.

return HTML::decorate(['class' => 'foo !span5'], ['class' => 'bar span5']);

// will return array('class' => 'foo bar');

Resources

Packages

No packages published

Languages

  • PHP 100.0%