TinyButStrong - the PHP Template Engine
Categories > TBS next version >

attadd adds space to existing attribute when empty

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Rudy
Date: 2009-07-02
Time: 10:53

attadd adds space to existing attribute when empty

Hi,

I noticed an odd behavior in the current 3.5 RC with the new att-fieldparameter. Let's consider we have the following:

<tr class="group">[user.class;att=class;attadd] ...

and we merge the data "user". When user.class is null, the code generated will be

<tr class="group ">

(notice the space at the end of the class). What it should produce is

<tr class="group">

without any space added. magnet=# does not help, because this of course will delete the whole attribute and deleting the class "group" defined in the template. But with a space at the end of the attribute you will have to trim the value everytime when evaluating it with javascript, which is not optimal. Is there a fast way to work around this or is it definitely a glitch to be resolved for 3.5 release?

Thanks for your help.
By: Skrol29
Date: 2009-07-05
Time: 10:46

Re: attadd adds space to existing attribute when empty

Hi Rudy,

TBS has this behavior because, in fact, moving the TBS fields into the attribute and replacing it with the value are two independent operations. TBS add a space for any value to merge because it doesn't know the value yet.

I agree the endding space is not optimized, I'll see if I can fix this. But I didn't know it could be a problem with Javascript. Why do you need to trim the value?
By: Skrol29
Date: 2009-07-15
Time: 21:39

Re: attadd adds space to existing attribute when empty

Hi Rudy,

This bug has been fixed with the last TBS beta version 3.05b2009-07-15, which available yet for download.
By: Rudy
Date: 2009-07-15
Time: 21:58

Re: attadd adds space to existing attribute when empty

Skrol, you are my man. Thank you very much.