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

add extra newline on every new file

 
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
DiLDoG
Smarty Rookie


Joined: 24 Aug 2003
Posts: 5

PostPosted: Sun Aug 24, 2003 1:10 pm    Post subject: add extra newline on every new file Reply with quote

How do I make smarty add a newline after every template I display?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Aug 24, 2003 10:23 pm    Post subject: Reply with quote

Hi.

You can register a postfilter that simply adds an extra linefeed.
Back to top
View user's profile Send private message
DiLDoG
Smarty Rookie


Joined: 24 Aug 2003
Posts: 5

PostPosted: Sun Aug 24, 2003 10:36 pm    Post subject: Reply with quote

hmm... tried that one already, but nothing happened
[php:1:ffb0071311]<?php
require("./smarty/Smarty.class.php");
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->caching = false;
$smarty->template_dir = './templates/';
$smarty->compile_dir = './smarty/templates_c/';
$smarty->register_postfilter("add_header_comment");
$smarty->display("header.tpl");

function add_header_comment($tpl_source, &$smarty)
{
return "<!-- Created by Smarty! -->".$tpl_source;
}
?>[/php:1:ffb0071311]

and an other question: is it possible to display the current template file name there, so for example <!-- header.tlp begins here -->
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Aug 24, 2003 10:47 pm    Post subject: Reply with quote

Well, you still need to embed the newline in the output. Do you want a newline char or a html <br/>? Or both?
[php:1:ee39b52e9e] return "<!-- Created by Smarty! -->".$tpl_source."<br/>\n";[/php:1:ee39b52e9e]It occurs to me that there is a way to get the current template name, but it escapes me at the moment. If I find it, I'll post back but messju probably knows off the top of his head Smile

This of course affects every processed template--I wasn't quite sure if that was what you meant.


Last edited by boots on Mon Aug 25, 2003 7:51 am; edited 1 time in total
Back to top
View user's profile Send private message
messju
Administrator


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

PostPosted: Mon Aug 25, 2003 6:27 am    Post subject: Reply with quote

boots wrote:
It occurs to me that there is a way to get the current template name, but it escapes me at the moment. If I find it, I'll post back but messju probably knows off the top of his head Smile


OTOH it's {$smarty.template} Smile .
Back to top
View user's profile Send private message Send e-mail 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