Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Precompiled templates

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
terryjohnson
Smarty Rookie


Joined: 03 Jan 2004
Posts: 9
Location: Chatham, ON, Canada

PostPosted: Sat Jan 03, 2004 5:21 pm    Post subject: Precompiled templates Reply with quote

Is it possible to pre-compile templates?

I know this defeats some of the advantages of Smarty, but it would make it easier to operate on a production site where safe_mode is on, which is the case for the majority of PHP web hosts, and quite useful even when running a on dedicated box.
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Jan 03, 2004 5:51 pm    Post subject: Reply with quote

if you don't want to compile on a production-server you can set $smarty->compile_check to false and upload the contents of templates_c manually. this should work.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
terryjohnson
Smarty Rookie


Joined: 03 Jan 2004
Posts: 9
Location: Chatham, ON, Canada

PostPosted: Sat Jan 03, 2004 8:57 pm    Post subject: Reply with quote

Turning off compile is a good feature, but what I was asking was whether it is possible to do something from the command prompt like:

[user lib]$ php Smarty_Compile.php ./templates/foo.tpl

so that the template can be coded, compiled and deployed without having to have an reasonable replica of the production environment to play with?
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Jan 03, 2004 9:27 pm    Post subject: Reply with quote

there is no public api to compile a template. the simplest way is to call $smarty->fetch($tpl) or $smarty->fetch($tpl, $cache_id, $compile_id).
Back to top
View user's profile Send private message Send e-mail Visit poster's website
terryjohnson
Smarty Rookie


Joined: 03 Jan 2004
Posts: 9
Location: Chatham, ON, Canada

PostPosted: Wed Jan 07, 2004 5:09 pm    Post subject: Reply with quote

OK I figured out how to do it by having a short php script in my development environment which can be passed template names as an argument:
Code:
<?php
/**
 * Smarty Compile 
 **/
require_once('Smarty.class.php');
$smarty =& New Smarty;
if (isset($_REQUEST['template'])) {
    $smarty->display($_REQUEST['template'].'.tpl');
} else {
    echo 'No template specified';
}
?>

Am I right in thinking that if I set compile to false in the production environment I can do away with the /templates folder and Smarty_Compiler.class.php altogther?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP