Categories > TinyButStrong general >

adding a character after a block, except if it's the last value

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: arkhi
Date: 2011-05-12
Time: 08:16

adding a character after a block, except if it's the last value

Hello everyone,

I'm just discovering TBS and quite enjoy it so far! Looks amazing to me.
There's still one problem I can't solve so far…
Let's say I have a series of links that I want to join with a coma:

<small><a>link1</a>, <a>link 2</a>, <a>link 3</a></small>

Of course, I don't want to have any coma after the last link.
Well, I can't figure out how to add those comas in between blocks, and not after the last link.

What I have so far is this code ("block" is a simple array):

<li class="genre">
  <small>
    <a href="#"><span itemprop="eventType">[block.val;block=a;bmagnet=li]</span></a>,
  </small>
</li>


If anybody can explain me how they'd do that, that'd be awesome, thanks! :)
By: Skrol29
Date: 2011-05-13
Time: 01:29

Re: adding a character after a block, except if it's the last value

Hello,

You can try with a conditional section, like this:

<li class="genre">
  <small>
    [block;block=begin;bmagnet=li;when [block.#]!=0], [block;block=end]
    <a href="#"><span itemprop="eventType">[block.val;block=a]</span></a>
  </small>
</li>
By: arkhi
Date: 2011-05-13
Time: 04:02

Re: adding a character after a block, except if it's the last value

Awesome.
I was keeping on searching for a solution _after_ the block while it makes a lot more sense to trigger the "always stable" first item.
Thanks a lot! It always seems so logic and easy once you got the solution. :)
It's also a very good thing that TBS is stripping white spaces.

I used this code since the first index is 1 and not 0 though:

<li class="genre">
  <small>
    [block;block=begin;bmagnet=li;when [block.#]!=1], [block;block=end]
    <a href="#"><span itemprop="eventType">[block.val;block=a]</span></a>
  </small>
</li>

Thanks again. :)