dev-master
9999999-dev https://github.com/livecms/transportsLive CMS Transports
MIT
by Mokhamad Rofiudin
Live CMS Transports
The idea is how to transport your code (HTML and Javascript) from your business logic (Model - Controller) into View., (*1)
Like a global variable, when can set and access it from anywhere in our code., (*2)
Currently we provide HTMLTransport and JavascriptTransport. For HTML Transport, you can give it the name each time you set (inserting) the code into it, just like a variable. For Javascript, you can not insert identical script, just to make sure you don't duplicate your javascript code., (*3)
Install via composer :, (*4)
``` shell composer require livecms/transports, (*5)
HTML : ``` php require vendor/autoload.php; $htmlTransport = new LiveCMS\Transport\HtmlTransport; // Set new transport with name 'form' $html = ' '; $htmlTransport->set($html, 'form'); // Set new transport with name 'message' $html = 'Hello, Admin'; $htmlTransport->set($html, 'message'); // Append code to 'form' $html = ' '; $htmlTransport->append($html, 'form'); // Show content of 'form' echo $htmlTransport->get('form'); /** Result : */ // Delete content of 'form' $htmlTransport->flush('form'); echo $htmlTransport->get('form'); /** Result : */ // Use method pull() to get content and delete it. echo $htmlTransport->pull('form'); // Delete all content $htmlTransport->flushAll(); echo $htmlTransport->get('message'); /** Result : */
Javascript :, (*6)
``` php, (*7)
require vendor/autoload.php;, (*8)
$jsTransport = new LiveCMS\Transport\JavascriptTransport;, (*9)
// Set new javascript code
$js = <<
// Adding another javascript code
$js = <<
// Adding another javascript code that same with previous, the code will not be saved.
$js = <<
// Show content echo $jsTransport->get();, (*13)
/** Result : $(':input').first().addClass('focus'); $('.message').text('Hi, bro. Whats up?'); */, (*14)
// Delete content $jsTransport->flush(); echo $jsTransport->get();, (*15)
/** Result : */ ```, (*16)
MIT, (*17)
Fork this repo and make a pull request, (*18)
Please create new issue or see the closed issues too., (*19)
Live CMS Transports
MIT