NN
nnixaa/InstantMessage
A small template engine that allows you easily render your emails, messages, etc. with file or database templates. It's really smaller and faster than View.
InstantMessages Tempalate Engine
This library is open source. Please help me by forking the project and adding to it.
About
A small template engine that allows you easily render your emails, messages, etc. with file or database templates.
It's really smaller and faster than Views.
Getting Started
Just create your template for message in application/views/scripts/imessages/hello.phtml
<div class="message">
<div class="name"><?php echo $this->name; ?></div>
<div class="text"><?php echo $this->text; ?></div>
</div>
Than fill messages in your controller with data
$substitution = array(
array('name' => 'Alex', 'date' => date('d-m-Y', strtotime('now')), 'text' => 'Test message from user 1'),
array('name' => 'Dmitry', 'date' => date('d-m-Y', strtotime('one hour ago')), 'text' => 'Test message from user 2'),
array('name' => 'Jack', 'date' => date('d-m-Y', strtotime('two hour ago')), 'text' => 'Hello world'),
);
$messages = InstantMessage_Broker::getInstance();
foreach ($substitution as $values)
{
$messages->addMessage('hello', $values, 'FileMessage', array('extension' => '.phtml'));
}
$this->view->messages = $messages->getMessages();
And render it in your base template (for ex. index.phtml)
<?php echo $this->renderMessages($this->messages); ?>
Or simply one message
$message = new InstantMessage_Message_FileMessage('hello', array('name' => 'Jack'));
$message->text = 'Hello world!';
$message->date = date('Y-m-d', time());
// or echo $message;
echo $message->render();
Demo
Soon
On this page
Languages
PHP89.3%JavaScript10.7%
Contributors
MIT License
Created August 25, 2011
Updated January 28, 2023