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

Smarty, gettext and modular template design

 
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
SlowFox
Smarty Regular


Joined: 02 Oct 2006
Posts: 55

PostPosted: Wed Jul 02, 2008 6:00 pm    Post subject: Smarty, gettext and modular template design Reply with quote

A very simple piece of HTML:
Code:
<img src="xxx.gif" alt="yyy">

is used quite often in a project. As it should be replaced throughout the
project by something else in a few installations, the idea is to relocate the
fragment in a separate template and call it via e.g.
Code:
{include file="xxx.tpl" alt="yyy"}

instead. This works fine. But now a) all the texts are translated via gettext,
and b) sometimes they are composed from variables, so the original may
as well look like
Code:
<img src="xxx.gif" alt="{t 1=$yyy|escape:"html"}abc %1 def{/t}">


I have absolutely no idea how to translate this into an {include} statement,
which is still elegant up to some point.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jul 02, 2008 6:28 pm    Post subject: Reply with quote

Perhaps you can modify the {t...} plugin that it optionally assigns its result to a SMARTY variable.

Your code could look like this:
Code:
{t 1=$yyy|escape:"html" assign="foo"}abc %1 def{/t}
{include file="xxx.tpl" alt=$foo}
Back to top
View user's profile Send private message
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