Skip to content
This repository has been archived by the owner on Feb 16, 2018. It is now read-only.
/ InstantMessage Public archive

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.

License

Notifications You must be signed in to change notification settings

nnixaa/InstantMessage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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 View.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published