tags:

views:

31

answers:

1

happy to see a sinatra-like microframework in php http://github.com/brucespang/Frank.php

but, documentation is scarce, and i'm not understading reading the code (maybe i'm not able):

you can define a views directory

set(array('views' => dirname(__FILE__) . '/templates'));

but how you can render file inside it?

how passing parameters?

there is no templating, simple php?

bye

A: 

If you take a look at the index.php file (I added comments myself):

// when you go to */template
get("/template", function(){
    // calls the template named "template" and passes variables to it
    render('template', array('locals' => array('name' => 'template'))); 
});

// setup the "template" named template
template("template", function($locals){
    echo 'Hello from '.$locals['name'];
});

It also says directly in the readme that it doesn't support any templating languages yet:

What Frank.php is missing:

  1. Spiffy template languages like haml and sass.template languages like haml and sass.

The framework looks far from complete, I probably wouldn't use it for anything essential.

evolve
if you create templates/test with some content and do render('test') it does display the content. but how i can pass vars to template?
giordano rossi
You pass the variables to it as the 2nd parameter of render(), for example `render('test', array('vars' => array('var1' => 'answer1')))`. Then you can call on that 'var1' by doing something similar to `$var['var1']` within the template.
evolve