Categories > TinyButStrong general >

TBS as registered view in Flight PHP framework

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Leo
Date: 2016-03-15
Time: 05:16

TBS as registered view in Flight PHP framework

Hello all. Long time no see.

I'm using a tiny useful framework called Flight ( Its basically a router
and pieces of good code which is OK for RESTful API's. I'm having some fun with it indeed.

But, you know, as a TBS fan I'm trying to override Its native (simple) view and put to work
a worthwhile template system.

The framework's example uses Smarty as alternative by a native class registering method
(I made a similar class register before for my ORM class and its running flawless). See Smarty's code below:

require './Smarty/libs/Smarty.class.php';

Flight::register('view', 'Smarty', array(), function($smarty){
    $smarty->template_dir = './templates/';
    $smarty->compile_dir = './templates_c/';
    $smarty->config_dir = './config/';
    $smarty->cache_dir = './cache/';

// Assign
Flight::view()->assign('name', 'Bob');

// Display

Flight::map('render', function($template, $data){

Does anyone tried this framework before with TBS? Any issue?
(That will be a FULL refactoring of legacy code. That's why I'm asking before start step on it.)

Please, any comment/suggestions will be useful.

Thanks in advance. / Merci pour votre attention.
By: Leo
Date: 2016-03-17
Time: 06:02

Re: TBS as registered view in Flight PHP framework

Hello again.

I'm reporting my test. Couldn't be more easy. I just started my refactoring.

include 'lib/tbs_class.php';

Flight::register('view', 'clsTinyButStrong', array(), function($tbs){});

Thats it. No TBS method left behind. No errors. No need for further method mapping.

The TBS class is good to go with Flight. (I just make a custom method
to compress the HTML output before the render, scrubbing me bytes
but its just my performance obsession).


    // Vars:
    Flight::view()->VarRef['name'] = 'Bob';

    // Blocks:
    $mylist = array('France'=>33, 'England'=>44, 'Spain'=>34, 'Italy'=>39, 'Deutchland'=>49);

    // Render:

(The template:)
<h1>Hello, []!</h1>
    <strong>That's your list:</strong>
        <li>[blk.#] [blk.key;block=li] ([blk.val])</li>

Any comments will be appreciated.

Thanks again and good bye.
By: Skrol29
Date: 2016-03-22
Time: 02:14

Re: TBS as registered view in Flight PHP framework

It seems so easy that a dedicated TBS plug-in seems unnecessary.

Thanks for your tip.