Re: #ECHO?
On Wed, Apr 2, 2008 at 3:34 AM, Thomas Sutton
<thomas@...> wrote:
> I implemented an #ECHO tag. It takes a single argument and returns it. It's
> of no use except as a way to get some text hard-coded in the template to
> some filters, e.g., image_typo. The only reason I want it is so that I can
> use image_typo to produce my hard-coded text in footers, "home" navigation
> links, etc:
OK I understand now.
What you wnt is exactly what already use the (bad commented) tags #GET / #SET
>
> [(#REM) Hard-coded text ]
> [(#ECHO{Copyright 2008 bouncingorange
> }|image_typo{police=silkscreen.ttf,taille=6})] [(#REM) Similarly treated
> dynamic text ]
You can do this :
#SET{copyright,Copyright 2008 bouncingorange}
[(#GET{copyright}image_typo{police=silkscreen.ttf,taille=6})]
> <BOUCLE_foot(RUBRIQUES){id_parent=5}{par num titre}> <li><a
> href="#URL_RUBRIQUE">[(#TITRE|supprimer_numero|image_typo{police=silkscreen.ttf,taille=6})]</a></li>
> </BOUCLE_foot>
>
>
> The question is about the interprete_argument_balise() function: can I
> assume that the values it returns are always safe to use in the $p->code
> value returned by a tag? According to Pierre the answer is yes: it should
> always be a piece of PHP code.
>
The solution is certainly in the code of #GET.
But in your case I don't think that it's necessary to re-invent the wheel..
>
>
> On Tue, Apr 1, 2008 at 6:28 AM, Thomas Sutton <thomas@...>
> wrote:
> Hi folks,
>
> I've wanted something like echo(1) in SPIP templates a few times (so
> that I can handle strings embedded in the templates in the same way
> as values from loops, etc.). While [(#REM|sinon{Stuff to echo}|...)]
> works, it is a bit dodgy, so I spent a few minutes and came up with
> the following:
>
>
> function balise_ECHO($p) {
> $p->code = "''";
> if (($v = interprete_argument_balise(1,$p))!==NULL){
> $p->code = $v;
> }
> return $p;
> }
>
> I doing so, I found that `interprete_argument_balise()` seems to
> return the value wrapped in ' and '. Is it safe to assume that
> `balise_...()` functions can always use values returned by
> `interprete_argument_balise()` as `$p->code` in this way?
>
> Regards,
>
>
>
> Thomas Sutton
> Web Developer
> bouncingorange
> graphic + web design