|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
SlowFox Smarty Regular
Joined: 02 Oct 2006 Posts: 55
|
Posted: Wed Jul 02, 2008 6:00 pm Post subject: Smarty, gettext and modular template design |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jul 02, 2008 6:28 pm Post subject: |
|
|
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 |
|
|
|
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
|