Changeset 687


Ignore:
Timestamp:
Jan 11, 2005, 10:44:31 PM (19 years ago)
Author:
plg
Message:
  • new methods parse and p (for print) : enable PhpWebGallery pages to be fully generated before being send to browser
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/template.php

    r675 r687  
    5656  // This will hold the uncompiled code for that handle.
    5757  var $uncompiled_code = array();
     58
     59  // output
     60  var $output = '';
    5861 
    5962  /**
     
    133136      eval($this->compiled_code[$handle]);
    134137      return true;
     138    }
     139
     140  /**
     141   * fills $output template var
     142   */
     143  function parse($handle)
     144    {
     145      if (!$this->loadfile($handle))
     146      {
     147        die("Template->pparse(): Couldn't load template file for handle $handle");
     148      }
     149     
     150      // actually compile the template now.
     151      if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
     152      {
     153        // Actually compile the code now.
     154        $this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle], true, '_str');
     155      }
     156
     157      // Run the compiled code.
     158      $_str = '';
     159      eval($this->compiled_code[$handle]);
     160      $this->output.= $_str;
     161
     162      return true;
     163    }
     164
     165  /**
     166   * prints $output template var
     167   */
     168  function p()
     169    {
     170      echo $this->output;
    135171    }
    136172 
Note: See TracChangeset for help on using the changeset viewer.