tags:

views:

24

answers:

1

Pure dwoo equivalent would be:

$dwoo->output('DwooTest/index', array('assignedVar' => 'Hello'));

(I am actually using it with codeigniter - with Phil Sturgeon's library):

$this->dwooParser->parse('DwooTest/index', array('assignedVar' => 'Hello'));

then inside index.php

{$assignedVar} //outputs 'Hello'

<?php
    $localVar = 'LocalVar';
?>

{$localVar}  //output: error

Is there a way to pass data from php inside the template to a dwoo var ?

Why I use this is because I have a view that needs some preprocessing of sorts (it sort of an advanced view, so I dont want to put the processing every time inside the controller ), inside the index.php I have a

require 'index.h.php' //(notation inspired from c++ header files)

In keeping with the above example, index.h.php would process $assignedVar, and put the data into $localVar, then the display of the data would take place inside the template index.php.

(Also on a side note, where is the documentation for this Dwoo thing... I mean that wiki... that is it ?)

A: 

That local variables are saved into an internal variable of the Dwoo object while the template is executed. The actual template code is executed within the Dwoo object's context, so you have access to its methods from php using $this.

The method you want in this case is assignInScope($val, $scope) that will assign it as such for example:

<?php $this->assignInScope('Hello', 'localVar'); ?>
{$localVar} // outputs Hello

You can also read from it with readVar($name), i.e.:

<?php echo $this->readVar('localVar'); ?> // outputs Hello again
Seldaek