[PHPTAL] Creating easy-to-write attribute values
Werner
lists at mollentze.co.za
Wed Jan 24 14:42:06 CET 2007
Thank you, very interesting solutions that sure show some potential to
be very groovy indeed. I think (3) will solve our problem easily.
Kind Regards,
Werner
Laurent Bedubourg wrote:
> Werner wrote:
>> Hi,
>>
>> Here follows some sample template markup that illustrates a very
>> common templating task:
>>
>> ...
>> <img tal:attributes="src string:$myImgBaseUrl/pic.png" alt="My Pic
>> With A Difficult-To-Write Base Url"/>
>> ...
>>
>> Yet, I cannot find a way to make it more efficient and (obviously)
>> easier to mark-up for template designers. Can anyone help me find a
>> way to make it simpler, say, to achieve something like this...
>>
>> ...
>> <img tal:attributes="src myImgBaseUrl/pic.png" alt="My Pic With An
>> Easier-To-Write Base Url"/>
>> ...
>>
>> The above would easily work with a predefined object passed from PHP
>> (so that PHPTAL can resolve the 'object path'), but keep in mind that
>> only the template designers know the location (and filenames) of the
>> page's images. The designer only knows that he/she would like to put
>> "pic.png" in there, and I don't want to make it difficult for them to
>> attach a shared image base url path to the image's markup, since only
>> the developers know the base url of the public image paths.
>>
>> Any groovy ideas?
>
> I don't know if they are groovy but they can be used :
>
>
> 0. Ensuring that the public image path is the same as the dev one, no
> code involved
>
> <img src="/img/pic.png" alt="bla bla"/>
>
>
> 1. Using a short notation (without tal:attributes)
>
> <img src="${imgBaseUrl}/pic.png" alt="bla bla"/>
>
>
> 2. Using a custom expression
>
> <img tal:attributes="src image:pic.png" alt="bla bla"/>
> <img src="${image:pub.png}" alt="bla bla"/>
>
> function phptal_tales_image($url){
> return "'http://data.mydomain.com/img/".$url."'";
> }
>
>
> 3. Using a PHPTAL Input filter to transform every src="/img/(.*?)"
> into src="http://data.mydomain.com/img/$1"
>
> <img src="/img/pic.png" alt="bla bla"/>
>
>
> 4. Any combinaison of above ideas but keep it simple !
>
>
> I would recommand solutions 0 or 3 to make your designers happy :)
>
> Regards
> Laurent
More information about the PHPTAL
mailing list