Download the PHP package taylornetwork/make-html without Composer
On this page you can find all versions of the php package taylornetwork/make-html. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download taylornetwork/make-html
More information about taylornetwork/make-html
Files in taylornetwork/make-html
Package make-html
Short Description A trait for to convert plain text to html, inlcuding links.
License
Informations about the package make-html
MakeHTML
This is a class and trait for Laravel that will convert text with line breaks and links into HTML. It also adds simple HTML tag generation as well as a helper function for imploding associative arrays.
Install
Via Composer
Dependencies
TaylorNetwork\MakeHTML
will install TaylorNetwork\LaravelHelpers. Laravel should auto discover that package, but if you run into problems you may need to include the provider manually.
Setup
This package is set up with auto discovery so you should be good to go out of the box. Check Manual Setup below if something isn't working.
Manual Setup
If auto discovery doesn't work...
Add the service provider to the providers array in config/app.php
.
Publishing
Run
This will add makehtml.php
to your config directory.
Usage
You can use this package either by including the trait in a class you want to implement the functionality or by creating a new instance of the class.
Trait
Import the trait into your class.
The MakeHTML trait includes two functions, usage examples below.
makeHTML (string $text)
Accepts one parameter, the text you want the generator to parse.
Given this example variable $text
Calling makeHTML
Returns
getHTMLGeneratorInstance ()
Accepts no parameters and returns an instance of HTMLGenerator class, or creates one.
You can chain any methods from the HTMLGenerator class onto that to return functionality.
See class usage below for examples.
Class
Instantiate the class.
Available Methods
makeLinks (string $text)
Converts any found links in the string to clickable links with <a>
tag.
Will take the base URL as the caption for the link.
For example:
Call makeLinks($textWithLink)
Returns
convertLineEndings (string $text)
Converts all line endings to HTML <br>
tags.
Call convertLineEndings($textWithLineBreaks)
Returns
makeHTML (string $text)
Calls convertLineEndings($text)
and makeLinks($text)
and returns the converted text.
generateTag (string $tag, array $attributes, boolean $closeTag = true)
Will generate an HTML tag with any attributes given.
To generate a <div>
tag with no attributes
Returns
To generate a <div>
tag with attributes
Call function
Returns
To generate a <div>
tag with attributes and also data between the tags, add the external
attribute and everything there will be added between the tags.
Call function
Returns
To generate a <div>
tag and keep it open, to process more external data for example.
Returns
closeTag(string $tag)
Closes a given tag
Returns
Magic Method
You can also call generateTag($tag, $attributes)
by calling the tag you want followed by Tag
To generate a <div>
tag this way
Would call generateTag('div', $attributes)
for you.
Config
The config file once published is in config/makehtml.php
Credits
- Main Author: Sam Taylor
License
The MIT License (MIT). Please see License File for more information.
All versions of make-html with dependencies
illuminate/support Version >=5.5
taylornetwork/laravel-helpers Version ^1.4