zordius/lightncandy — pull request #31 by zordius (2014-04-17 03:09:24+00:00)
Title: new extended helper encode/escape logic, fix php warning

The may resolve #25 and #28 .

My design is to prevent the creation of new class/method.
Maybe this can fit into your requirement.
If this can not fullfill your usecase, please let me know, thanks.

**Here is the updated document**

The return value of your custom helper should be a string. When your custom helper be executed from {{ }} , the return value will be HTML encoded. You may execute your helper by {{{ }}} , then the original helper return value will be outputted directly.

When you need to do different escaping or encoding logic, you can return extended information by Array($responseString, $escape_flag) , here are some custom helper return value cases:

```php
// encode is handled by lightncandy and decided by template
// if the helper is in {{ }} , you get 'The U&ME Helper is ececuted!'
// if the helper is in {{{ }}} , you get 'The U&ME Helper is executed!'
return 'The U&ME Helper is executed!';

// Same as above because the escape_flag is DEFAULT
// 0, false, null, undefined, or '' means DEFAULT
return Array('The U&ME Helper is executed!');
return Array('The U&ME Helper is executed!', false);
return Array('The U&ME Helper is executed!', 0);

// encoding is handled by the helper, lightncandy will do nothing
// No matter in {{ }} or {{{ }}} , you get 'Exact&Same output \' \" Ya!'
return Array('Exact&Same output \' " Ya!', 'raw');

// force lightncandy html_encoded the helper result
// No matter in {{ }} or {{{ }}} , you get 'Not&Same output ' " Ya!'
return Array('Not&Same output \' " Ya!', 'enc');

// force lightncandy encoded the helper result in handlebars.js way
// No matter in {{ }} or {{{ }}} , you get 'Not&Same output ' " Ya!'
return Array('Not&Same output \' " Ya!', 'encq');
```